Skip to content

Commit

Permalink
update(Log): Improve logs on console (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgmarchi authored Oct 26, 2024
1 parent ed21ae3 commit b736e79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/lib/utils/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export class Logger {
console.warn(`[${level.toString()}] (${new Date().toLocaleTimeString()}): ${message}`, ...other)
break
}
case LogLevel.Info: {
console.info(`\x1b[32mℹ️ [${level.toString()}] (${new Date().toLocaleTimeString()}): ${message}\x1b[0m`, ...other)
break
}
default: {
console.log(`[${level.toString()}] (${new Date().toLocaleTimeString()}): ${message}`, ...other)
console.log(`\x1b[36m🔍 [${level.toString()}] (${new Date().toLocaleTimeString()}): ${message}\x1b[0m`, ...other)
break
}
}
Expand Down
23 changes: 18 additions & 5 deletions src/lib/wasm/MultipassStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ class MultipassStore {
outgoingFriendRequestsUsers
)
} catch (error) {
log.error("Error listing incoming friend requests: " + error)
let messageError: string = `${error}`
if (messageError !== "Error: MultiPass extension is unavailable") {
log.error("Error listing outgoing friend requests: " + error)
}
}
}
}
Expand Down Expand Up @@ -336,7 +339,10 @@ class MultipassStore {
get(Store.state.activeRequests).filter(r => r.direction === MessageDirection.Outbound)
)
} catch (error) {
log.error("Error listing incoming friend requests: " + error)
let messageError: string = `${error}`
if (messageError !== "Error: MultiPass extension is unavailable") {
log.error("Error listing incoming friend requests: " + error)
}
}
}
}
Expand All @@ -361,7 +367,10 @@ class MultipassStore {
}
Store.setBlockedUsers(blockedUsers)
} catch (error) {
log.error("Error listing blocked friends: " + error)
let messageError: string = `${error}`
if (messageError !== "Error: MultiPass extension is unavailable") {
log.error("Error listing blocked friends: " + error)
}
}
}
}
Expand All @@ -386,7 +395,10 @@ class MultipassStore {
}
Store.setFriends(friendsUsers)
} catch (error) {
log.error("Error listing friends: " + error)
let messageError: string = `${error}`
if (messageError !== "Error: MultiPass extension is unavailable") {
log.error("Error listing friends: " + error)
}
}
}
}
Expand Down Expand Up @@ -653,7 +665,8 @@ class MultipassStore {
}
}
}
if (lastErr) {
let lastErrStr = `${lastErr}`
if (lastErr && lastErrStr !== "Error: Identity does not exist") {
log.error(`Couldn't fetch identity ${id}: ${lastErr}`)
}
return undefined
Expand Down

0 comments on commit b736e79

Please sign in to comment.