Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow logging to be disabled #880

Merged
merged 3 commits into from Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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