feat(logger): add [BAILEYS] console-friendly logging functions
Add formatted logging functions with [BAILEYS] prefix and emojis: - logEventBuffer: buffer events (📦, 🔄, ⚠️, ⏰, 🧹, 🧠) - logBufferMetrics: metrics display (📊) - logMessageSent/Received: message events (📤, 📥) - logConnection: connection events (🔌, ✅, 🔴, 🔄, ❌) - logAuth: authentication events (📱, 🔑, 🚪, 🔐) - logCircuitBreaker: circuit breaker state (⚡, ✅, 🔶) - logRetry: retry attempts (🔁) - logInfo/Warn/Error: generic messages (ℹ️, ⚠️, ❌) - logLidMapping: LID store events (🗂️, 🔍, 💾, 📦) All functions respect BAILEYS_LOG=false environment variable. Integrated into event-buffer.ts and messages-send/recv.ts.
This commit is contained in:
@@ -16,6 +16,7 @@ import type {
|
||||
WAPatchName
|
||||
} from '../Types'
|
||||
import { WAMessageStatus, WAMessageStubType } from '../Types'
|
||||
import { logMessageReceived } from '../Utils/baileys-logger'
|
||||
import {
|
||||
aesDecryptCTR,
|
||||
aesEncryptGCM,
|
||||
@@ -1318,6 +1319,11 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
cleanMessage(msg, authState.creds.me!.id, authState.creds.me!.lid!)
|
||||
|
||||
await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify')
|
||||
|
||||
// Log with [BAILEYS] prefix
|
||||
if (msg.key.id && msg.key.remoteJid) {
|
||||
logMessageReceived(msg.key.id, msg.key.remoteJid)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
logger.error({ error, node: binaryNodeToString(node) }, 'error in handling message')
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
WAMessage,
|
||||
WAMessageKey
|
||||
} from '../Types'
|
||||
import { logMessageSent } from '../Utils/baileys-logger'
|
||||
import {
|
||||
aggregateMessageKeysNotFromMe,
|
||||
assertMediaContent,
|
||||
@@ -1034,6 +1035,9 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
|
||||
await sendNode(stanza)
|
||||
|
||||
// Log with [BAILEYS] prefix
|
||||
logMessageSent(msgId, destinationJid)
|
||||
|
||||
// Add message to retry cache if enabled
|
||||
if (messageRetryManager && !participant) {
|
||||
messageRetryManager.addRecentMessage(destinationJid, msgId, message)
|
||||
|
||||
Reference in New Issue
Block a user