Skip to content

Commit

Permalink
fix: don't format log message if logging is disable (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jan 13, 2020
1 parent 87c2819 commit b7b5fc9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 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) => {};
let logFunction: ((msg: string) => void) | undefined = undefined;

/**
* Log function to use for debug output. By default, we don't perform any
Expand All @@ -38,12 +38,14 @@ export function logger(
): void {
requestTag = requestTag || '#####';

const formattedMessage = util.format(logMessage, ...additionalArgs);
const time = new Date().toISOString();
logFunction(
`Firestore (${libVersion}) ${time} ${requestTag} [${methodName}]: ` +
formattedMessage
);
if (logFunction) {
const formattedMessage = util.format(logMessage, ...additionalArgs);
const time = new Date().toISOString();
logFunction(
`Firestore (${libVersion}) ${time} ${requestTag} [${methodName}]: ` +
formattedMessage
);
}
}

/**
Expand Down

0 comments on commit b7b5fc9

Please sign in to comment.