UNPKG

@duffel/components

Version:

Component library to build your travel product with Duffel.

47 lines (46 loc) 1.7 kB
/** * The functions in this file are used to enable logging. * * Usage: * * In your app's outermost container, import the LogContext and wrap your app in it: * * ```jsx * import { LogContext, initializeLogger } from '@lib/logging' * * const logger = initializeLogger(props.debugMode || false) * * <LogContext.Provider value={logger}> * ... * </LogContext.Provider> * ``` * * Then in your components nested within the above container, import the useLog hook and use it: * * import { useLog } from '@lib/logging' * * const { log, logGroup } = useLog() * log('This is a log message') * logGroup('These messages will be grouped together', ['This is a log message', 'This is another log message']) */ declare const initializeLogger: (debugMode: boolean) => void; /** * Log a message to the console. Messages will be prefixed with "[Duffel Ancillaries]". * @param message The message to print to the console. */ declare const log: (message: any) => void; /** * Log a series of messages to the console inside a collapsible group. * @param groupName The name of the group of messages. This will be prefixed with "[Duffel Ancillaries]". * @param messages An array of messages to print to the console, inside the group. */ declare function logGroup(groupName: string, messages: any[]): void; /** * Log a series of messages to the console inside a collapsible group. * @param groupName The name of the group of messages. This will be prefixed with "[Duffel Ancillaries]". * @param object An object to print to the console, inside the group. */ declare function logGroup(groupName: string, object: { [key: string]: any; }): void; export { initializeLogger, log, logGroup };