Make "logger" optional (#772)

This commit is contained in:
allburov
2024-05-15 22:33:22 +07:00
committed by GitHub
parent ce325d1182
commit 17ce9df557

View File

@@ -29,7 +29,7 @@ export const waLabelAssociationKey: Comparable<LabelAssociation, string> = {
export type BaileysInMemoryStoreConfig = {
chatKey?: Comparable<Chat, string>
labelAssociationKey?: Comparable<LabelAssociation, string>
logger: Logger
logger?: Logger
socket?: WASocket
}
@@ -73,13 +73,12 @@ const predefinedLabels = Object.freeze<Record<string, Label>>({
}
})
export default (
{ logger, chatKey, labelAssociationKey, socket }: BaileysInMemoryStoreConfig
) => {
export default (config: BaileysInMemoryStoreConfig) => {
// const logger = _logger || DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' })
chatKey = chatKey || waChatKey(true)
labelAssociationKey = labelAssociationKey || waLabelAssociationKey
logger = logger || DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' })
const socket = config.socket
const chatKey = config.chatKey || waChatKey(true)
const labelAssociationKey = config.labelAssociationKey || waLabelAssociationKey
const logger: Logger = config.logger || DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' })
const KeyedDB = require('@adiwajshing/keyed-db').default
const chats = new KeyedDB(chatKey, c => c.id) as KeyedDB<Chat, string>