Skip to content

@firebase/logger #473

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

Merged
merged 24 commits into from
Feb 28, 2018
Merged

@firebase/logger #473

merged 24 commits into from
Feb 28, 2018

Conversation

jshcrowthe
Copy link
Contributor

This PR has two parts, 1) the @firebase/logger module and 2) the integrations with @firebase/database and @firebase/firestore.

@firebase/logger

This module exports a class called Logger which supports the following 5 log methods:

  • debug
  • log
  • info
  • warn
  • error

Log Handlers

Each instance of logger, will, by default, log to the corresponding console method (i.e. console.debug, console.log, console.info, console.warn, console.error), however the logHandling itself is customizable by passing a new logHandler function to a Logger instance.

Each log handler has the following signature:

export type LogHandler = (
  logType: LogLevel,
  currentLogLevel: LogLevel,
  ...args: any[]
) => void;

The handler is passed:

  • the intended log type (i.e. did I call the log method, or the error method of my Logger instance?)
  • the current log level (i.e. LogLevel.VERBOSE, or LogLevel.ERROR, etc. This will be discussed in more detail below)
  • An array of arguments to actually log

The default handler, respects the passed log level, and if it is a valid log, passes it on to the appropriate console stream.

You can define other handlers on an as needed basis.

Log Levels

We support 5 "active" levels and a "silent" mode for our logs. The full log set we support will be:

export enum LogLevel {
  DEBUG,
  VERBOSE,
  INFO,
  WARN,
  ERROR,
  SILENT
}

All of the log levels besides LogLevel.SILENT map to a console value and should be used instead of the console functions (to allow us to centralize logging for the SDK). LogLevel.SILENT, by default, disables the logs (however each LogHandler can decide what it wants to do with this level).

Integrations with other SDKs

@firebase/database

See f5ad492 for detailed diff

I replaced the logging utilities found in https://github.com/firebase/firebase-js-sdk/blob/logger/packages/database/src/core/util/util.ts, these are used throughout the SDK which quickly propagated the change to the rest of the database SDK. We have not yet exposed the log levels here.

All of the enableLogging functionality remained unchanged.

@firebase/firestore

See 4e59a63 for detailed diff

I replaced the logging utilities found in https://github.com/firebase/firebase-js-sdk/blob/logger/packages/firestore/src/util/log.ts. Firestore uses a subset of the log types we intend to support and as such a small map was required.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, but got some feedback / suggestions for ya. :-)

if ('msg' in body && typeof console !== 'undefined') {
console.log('FIREBASE: ' + body['msg'].replace('\n', '\nFIREBASE: '));
if ('msg' in body) {
log('FIREBASE: ' + body['msg'].replace('\n', '\nFIREBASE: '));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was explicitly meant to be logged without turning on logging. Essentially you can use a special auth token and the backend will send back debug messages that get automatically logged to the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@@ -653,7 +653,7 @@ export class Repo {
forEach(stats, (stat: string, value: any) => {
// pad stat names to be the same length (plus 2 extra spaces).
for (let i = stat.length; i < longestName + 2; i++) stat += ' ';
console.log(stat + value);
log(stat + value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is actually meant to be logged to the console, without enabling any logging settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@@ -19,37 +19,42 @@
import { SDK_VERSION } from '../core/version';
import { AnyJs } from './misc';
import { PlatformSupport } from '../platform/platform';
import { Logger, LogLevel as _LogLevel } from '@firebase/logger';

const client = new Logger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client => firebaseLogger? (or at least logClient or similar)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logClient is the name used in packages/database/src/core/util/util.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@@ -19,37 +19,42 @@
import { SDK_VERSION } from '../core/version';
import { AnyJs } from './misc';
import { PlatformSupport } from '../platform/platform';
import { Logger, LogLevel as _LogLevel } from '@firebase/logger';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_LogLevel => FirebaseLogLevel ? (maybe Logger => FirebaseLogger too for symmetry)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

}
export function setLogLevel(newLevel: LogLevel): void {
logLevel = newLevel;
client.logLevel = newLevel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this do the inverse LogLevel => _LogLevel mapping as getLogLevel()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we don't have to because the 3 log types that Firestore supports are supported by the Logger package itself. This just works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, and TypeScript is validating that I guess (if you added a different entry to Firestore's LogLevel, typescript would complain?).

If so, cool though I'd still probably add a comment to that effect:

// Since Firestore's LogLevel enum is a pure subset of Firebase's LogLevel, we can return it directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/**
* A function to set the default log level externally
*/
export function setDefaultLogLevel(val: LogLevel) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this function for? Setting the default seems nonintuitive (the default is what you get if you don't set the log level).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was originally to help with some testing and I thought it might be nice to allow people to set the default and have it persist. Per feedback here, I've removed it.

*/
export function setDefaultLogLevel(val: LogLevel) {
if (!(val in LogLevel)) {
throw new TypeError('Attempted to Invalid value assigned to `logLevel`');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grammar malfunction (here and below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to get like a grammar checker for my code haha.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also would be nice to include the value here.

console.error(...args);
break;
default:
console.debug(...args);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://developer.mozilla.org/en-US/docs/Web/API/Console: Starting with Chromium 58 this method only appears in Chromium browser consoles when level "Verbose" is selected.

Which means we don't want to do it (developers shouldn't have to opt into logs twice to get them).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll refactor this to a console.log

case LogLevel.SILENT:
return;
case LogLevel.VERBOSE:
console.log(...args);
Copy link
Contributor

@mikelehen mikelehen Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format in your proposal was:

[<timestamp>]  <name>@<version>: <message>

Are we not doing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch on this, I forgot it entirely. I'll rev this appropriately

if (!(val in LogLevel)) {
throw new TypeError('Attempted to Invalid value assigned to `logLevel`');
}
defaultLogLevel = val;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm... So if you call setDefaultLogLevel(), which I assume will be the public API we eventually expose to users, shouldn't we notify all of the existing instances? As a user I should be able to enable / disable logging at will.

I'm fuzzy on how the global and per-component log levels are meant to interact. E.g. what happens if I set the default one, then set a per-component one, then set the default one again?

Honestly I would just simplify and only have the default / global log level for now. But if you keep both, please make sure they interact in a sane way (taking into consideration how you expect to expose the API to the end user eventually).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go even further and suggest that we only need to set the default log level for the Firebase logger. If a user specifies their own logger, they can strip out log messages as they deem necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to make it so that each log client can set their own log levels (e.g. Database and Firestore, currently, can't rely on a single log level as they are handled separately). Though there are other ways you could solve this, I've opted to just keep the LogLevel, local to the Logger instance.

I've removed the global default thing, so that is gone.

There is still a top level "set-all" type of functionality. This will allow us to do global level sets across all Logger instances which we will need going forward.

@mikelehen mikelehen removed their assignment Jan 31, 2018
@@ -19,37 +19,42 @@
import { SDK_VERSION } from '../core/version';
import { AnyJs } from './misc';
import { PlatformSupport } from '../platform/platform';
import { Logger, LogLevel as _LogLevel } from '@firebase/logger';

const client = new Logger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logClient is the name used in packages/database/src/core/util/util.ts.

@@ -179,14 +167,8 @@ export const fatal = function(...var_args: string[]) {
* @param {...*} var_args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is for the hidden block just above (line 173): I feel that we should also log 'fatal' messages to the user-specified log functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
export function setDefaultLogLevel(val: LogLevel) {
if (!(val in LogLevel)) {
throw new TypeError('Attempted to Invalid value assigned to `logLevel`');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also would be nice to include the value here.

*/
export type LogHandler = (
logType: LogLevel,
currentLogLevel: LogLevel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make sure these names match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored this a bit PTAL

if (!(val in LogLevel)) {
throw new TypeError('Attempted to Invalid value assigned to `logLevel`');
}
defaultLogLevel = val;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go even further and suggest that we only need to set the default log level for the Firebase logger. If a user specifies their own logger, they can strip out log messages as they deem necessary.

* centrally set, each logger can be set individually if it desires.
*/
private _logLevel = defaultLogLevel;
get logLevel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add typings here and below.

}
set logLevel(val) {
if (!(val in LogLevel)) {
throw new TypeError('Attempted to Invalid value assigned to `logLevel`');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure this message is also updated.

};
/**
* Before each test, instantiate a new instance of Logger and set the log
* level so that all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please finish your thought :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

/**
* The log handler for the current logger instance. This can be set to any
* function value, though this should not be needed the vast majority of the
* time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the second sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more feedback. I'm still not thrilled with the set of LogLevels we're landing on (and I'm confused about the intent of LOG / DEBUG since you seem to be (intentionally?) merging them into console.log calls). It probably makes sense to come to consensus on the set of LogLevels and their behavior before doing another full round of code review. Feel free to comment here or ping me directly or whatever.

console.log(`Firestore (${SDK_VERSION}) ${time} [${tag}]: ${msg}`, ...args);
logClient.log(
`Firestore (${SDK_VERSION}) ${time} [${tag}]: ${msg}`,
...args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we logging time twice now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I have pulled this from these logs.

logLevel = newLevel;
/**
* Since Firestore's LogLevel enum is a pure subset of Firebase's LogLevel, we
* can return it directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I'm 90% sure this doesn't actually work. At runtime, newLevel is just going to be a number (e.g. 1, corresponding to ERROR) and it's going to get assigned to logClient.logLevel as a number (e.g. 1, now corresponding to LOG). I really don't know why TypeScript even compiles this. :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored this to do a manual set. PTAL.

}

export function debug(tag: string, msg: string, ...obj: AnyJs[]): void {
if (logLevel <= LogLevel.DEBUG) {
if (logClient.logLevel <= FirebaseLogLevel.DEBUG) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you intentionally comparing to DEBUG and then using .log() below [as opposed to .debug]? I'm guessing this should be .LOG here, but then we also need to change the setLogLevel() code above to map Firestore's DEBUG LogLevel to Firebase's LOG LogLevel...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch here, refactored the logging call to logClient.debug

instance:

- `debug`: Internal logs; use this to allow developers to send us their debug
logs for us to be able to diagnose an issue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So console.debug() logs are disabled by default in Chrome Dev Tools (the developer needs to explicitly change the log filter to "verbose.") This means that to get these logs from a developer we would need to tell them to set the LogLevel to DEBUG and change the filter in chrome dev tools. We don't want to make them do two steps (and in general there's no reason to have two gates for enabling / disabling our logs).

So I think we should avoid using console.debug() entirely. It'll just cause confusion. This means we need to either drop LogLevel.DEBUG or make it use console.log() [in which case we should drop LogLevel.LOG]. My preference is for dropping LogLevel.LOG.

Copy link
Contributor Author

@jshcrowthe jshcrowthe Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a comment in logger.ts to explain this and I am now intentionally routing debug logs to console.log.

I feel like there is still a valid distinction to be made between LogLevel.INFO and LogLevel.LOG.

Some strawmen for examples:

LogLevel.INFO: If a user doesn't initialize an app with all of the config required to init all the services (think, if we add a new field to that config), this would be a good INFO candidate. It's not immediately breaking, and a user has an action item they can take to alleviate the issue.

LogLevel.LOG: If a user is trying to use some feature that has suffers from unsolvable performance issues in Hybrid environments, we may Log a message notifying the user that there is some known slowness.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's an action item for the user, wouldn't we want the log on by default? INFO logs are off by default, so that would not be appropriate.

But my bigger problem is that "LOG" is meaningless since these are all logs and I've never come across another logging system that has "LOG" as its own log level so nobody will know what this means or where it fits in the overall ordering. Even other JavaScript loggers (where log as a loglevel might almost make sense because of the console.log legacy) don't have it...

winston [10k stars] - error, warn, info, verbose, debug
bunyan [5k stars] - fatal, error, warn, info, debug, trace
loglevel [1k stars] - error, warn, info, debug, trace

So I appreciate that you've made up your own level and have strawmen examples to back it up, but I think it would be better to stick with well-known ones.

I think in practice:

  1. 90% of customers will stick with the default (warn and error) all the time.
  2. 10% of customers may enable debug logging because support asked them to or they found a StackOverflow / forum post that mentions it.
  3. 0% of customers will care to distinguish between info/log/debug.
  4. Only Firestore and RTDB use these logs and they only have error, warn, and debug. So there's currently no distinction to make anyway.

All that said, I don't really care. I think we should avoid LOG. If you think we need 5 log levels instead of 4 or 3, then please pick from the existing set of log levels that other systems use (notice, verbose, trace, etc.) for your 5th. Keep in mind we could always add more log levels later if we need them.


- `debug`: Internal logs; use this to allow developers to send us their debug
logs for us to be able to diagnose an issue.
- `log`: Use to inform your user about things they may need to know.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned, I'd like to drop "log" but if we keep it, can you make this description clearer? Is "your user" the Firebase end developer? And what does "may need to know" mean? Perhaps an example would help.

case LogLevel.ERROR:
console.error(`[${now}] ${instance.name}:`, ...args);
break;
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You left out DEBUG
  2. Rather than default to console.log(), I'd throw an exception. That way you'll notice if you leave out a log level. If for some reason you were intentionally handling DEBUG via the default: case, then a comment is warranted to explain your intent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

/**
* A container for the default log level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be "The Default Log Level" (I'm not sure what 'container' refers to)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.


function testLog(message, channel, shouldLog) {
/**
* `debug` logs also go through log channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggests you are currently intentionally merging log and debug messages, but I didn't see this explained anywhere... Did I miss it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled the beforeEach. Things should be working as expected.

const message = 'Hello there!';
let client: Logger;
const spies = {
debugSpy: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

testLog(message, 'error', true);
});

describe('Defaults', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this test different than the above one other than it's using WARN instead of DEBUG as the log level? Perhaps it should omit the beforeEach() so that we actually get the default log level automatically? And then the describe should be something like "Defaults to LogLevel.WARN" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

@@ -40,7 +40,7 @@ export enum LogLevel {
}

/**
* A container for the default log level
* The sefault log level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sefault => default

* are early returning here. To allow custom log handlers to handle this
* behavior differently, we are still going to pass through logging calls
* to their handlers when the log level is set to `SILENT`.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand this. AFAICT, there's currently no way for logType to be SILENT since there's no Logger.silent(...) method and it would never make sense to have one. So I think we should not have a case for SILENT and it should fall through to default: and throw.

@@ -52,13 +51,14 @@ describe('@firebase/logger', () => {

function testLog(message, channel, shouldLog) {
/**
* `debug` logs also go through log channel
* Ensure that `debug` logs assert against the `console.log` function. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"assert against" doesn't seem like the right wording here. Perhaps just "via"?

instance:

- `debug`: Internal logs; use this to allow developers to send us their debug
logs for us to be able to diagnose an issue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's an action item for the user, wouldn't we want the log on by default? INFO logs are off by default, so that would not be appropriate.

But my bigger problem is that "LOG" is meaningless since these are all logs and I've never come across another logging system that has "LOG" as its own log level so nobody will know what this means or where it fits in the overall ordering. Even other JavaScript loggers (where log as a loglevel might almost make sense because of the console.log legacy) don't have it...

winston [10k stars] - error, warn, info, verbose, debug
bunyan [5k stars] - fatal, error, warn, info, debug, trace
loglevel [1k stars] - error, warn, info, debug, trace

So I appreciate that you've made up your own level and have strawmen examples to back it up, but I think it would be better to stick with well-known ones.

I think in practice:

  1. 90% of customers will stick with the default (warn and error) all the time.
  2. 10% of customers may enable debug logging because support asked them to or they found a StackOverflow / forum post that mentions it.
  3. 0% of customers will care to distinguish between info/log/debug.
  4. Only Firestore and RTDB use these logs and they only have error, warn, and debug. So there's currently no distinction to make anyway.

All that said, I don't really care. I think we should avoid LOG. If you think we need 5 log levels instead of 4 or 3, then please pick from the existing set of log levels that other systems use (notice, verbose, trace, etc.) for your 5th. Keep in mind we could always add more log levels later if we need them.

@mikelehen mikelehen assigned jshcrowthe and unassigned mikelehen Feb 28, 2018
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit left, but otherwise LGTM.

) => void;

/**
* The default log handler will forward DEBUG, LOG, INFO, WARN, and ERROR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG => VERBOSE

# @firebase/logger

This package serves as the base of all logging in the JS SDK. Any logging that
is intended to be for firebase end developers, should go through this module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comma and maybe reword as:

This package serves as the base of all logging in the JS SDK. Any logging that
is intended to be visible to Firebase end developers should go through this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- `info`: Use if you have to inform the user about something that they need to
take a concrete action on. Once they take that action, the log should go away.
- `warn`: Use when a product feature may stop functioning correctly; unexpected
scenario. Majority of user-facing logs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd take out "Majority of user-facing logs.". This is likely only true when the user doesn't enable debug logging.

* DEBUG < VERBOSE < INFO < WARN < ERROR
*
* All of the log types above the current log level will be captured (i.e. if
* I set the log level to `INFO`, errors will still be logged, but `DEBUG` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... "if YOU set the log level" ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* The log level of the given Logger instance.
*/
private _logLevel = defaultLogLevel;
get logLevel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return type.

Do we need to add add proper JSDoc to each of these methods? Or will you do this as part of firebase-types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

No, this module is only internally used for the time being. When we actually surface it to end developers, we'll take care of the typings.

get logLevel() {
return this._logLevel;
}
set logLevel(val) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add argument type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* The log handler for the Logger instance.
*/
private _logHandler: LogHandler = defaultLogHandler;
get logHandler() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

get logHandler() {
return this._logHandler;
}
set logHandler(val) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add argument type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants