Skip to content

Commit

Permalink
feat: allow logging to be disabled (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jan 14, 2020
1 parent 9169fae commit 36d75f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions dev/src/logger.ts
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down
7 changes: 5 additions & 2 deletions types/firestore.d.ts
Expand Up @@ -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.
Expand Down

0 comments on commit 36d75f6

Please sign in to comment.