diff --git a/dev/src/logger.ts b/dev/src/logger.ts index 28296f3f1..c0b3cb07f 100644 --- a/dev/src/logger.ts +++ b/dev/src/logger.ts @@ -22,7 +22,7 @@ import {validateFunction} from './validate'; let libVersion: string; /*! The external function used to emit logs. */ -let logFunction: ((msg: string) => void) | undefined = undefined; +let logFunction: ((msg: string) => void) | null = null; /** * Log function to use for debug output. By default, we don't perform any @@ -49,15 +49,18 @@ export function logger( } /** - * Sets the log function for all active Firestore instances. + * Sets or disables the log function for all active Firestore instances. + * + * @param logger A log function that takes a message (such as `console.log`) or + * `null` to turn off logging. */ -export function setLogFunction(logger: (msg: string) => void): void { +export function setLogFunction(logger: ((msg: string) => void) | null): void { validateFunction('logger', logger); logFunction = logger; } /** - * Sets the log function for all active Firestore instances. + * Sets the library version to be used in log messages. * * @private */ diff --git a/types/firestore.d.ts b/types/firestore.d.ts index c6f5f1533..038c90018 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -35,9 +35,12 @@ declare namespace FirebaseFirestore { export type UpdateData = {[fieldPath: string]: any}; /** - * Sets the log function for all active Firestore instances. + * Sets or disables the log function for all active Firestore instances. + * + * @param logger A log function that takes a message (such as `console.log`) or + * `null` to turn off logging. */ - function setLogFunction(logger: (msg:string) => void): void; + function setLogFunction(logger: ((msg:string) => void) | null) : void; /** * Settings used to directly configure a `Firestore` instance.