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