Skip to content

Warn when stream is closing due to error, not debug. #3064

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 6 commits into from
Jun 1, 2020

Conversation

wu-hui
Copy link
Contributor

@wu-hui wu-hui commented May 14, 2020

b/155897356

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Let's chat about this quickly in API discussion. We currently don't have a way for users to set the log level to "warn": https://firebase.google.com/docs/reference/js/firebase.firestore#setloglevel

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 23, 2020

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (67adfb2) Head (0b1a8f2) Diff
    browser 251 kB 250 kB -1.16 kB (-0.5%)
    esm2017 195 kB 194 kB -911 B (-0.5%)
    main 494 kB 492 kB -2.01 kB (-0.4%)
    module 249 kB 248 kB -1.21 kB (-0.5%)
  • @firebase/firestore/lite

    Type Base (67adfb2) Head (0b1a8f2) Diff
    main ? 6.51 kB ? (?)
  • @firebase/firestore/memory

    Type Base (67adfb2) Head (0b1a8f2) Diff
    browser 192 kB 191 kB -810 B (-0.4%)
    esm2017 149 kB 149 kB -676 B (-0.5%)
    main 370 kB 368 kB -1.26 kB (-0.3%)
    module 190 kB 189 kB -853 B (-0.4%)
  • @firebase/util

    Type Base (67adfb2) Head (0b1a8f2) Diff
    browser 19.5 kB 19.6 kB +143 B (+0.7%)
    esm2017 17.4 kB 17.5 kB +126 B (+0.7%)
    main 19.5 kB 19.6 kB +143 B (+0.7%)
    module 18.6 kB 18.7 kB +126 B (+0.7%)
  • firebase

    Type Base (67adfb2) Head (0b1a8f2) Diff
    firebase-firestore.js 290 kB 289 kB -1.21 kB (-0.4%)
    firebase-firestore.memory.js 232 kB 231 kB -859 B (-0.4%)
    firebase.js 823 kB 822 kB -1.21 kB (-0.1%)

Test Logs

@wu-hui wu-hui force-pushed the wuandy/WarnOnStreamError branch from 6722078 to db25c5f Compare May 24, 2020 00:09
@wu-hui wu-hui assigned hsubox76 and schmidt-sebastian and unassigned wu-hui May 25, 2020
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Thanks for updating this. Please remember to get sign off by the API council.

// The default log level is error
return 'error';
}
static get logLevel(): 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 change this back to firestore.LogLevel, remove the use of the LogLevel type (we should only use LogLevelString) and change the typings for firestore.LogLevel to match the log types in Util?

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.

import { SDK_VERSION } from '../core/version';
import { PlatformSupport } from '../platform/platform';

export { LogLevel };
export { LogLevel, LogLevelString };
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably don't need to export these anymore. Instead, you can rely on the fact that our typings now match the types in @firebase/logger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

static get logLevel(): firestore.LogLevel from database.ts still needs it to return the string values.

}

static setLogLevel(level: firestore.LogLevel): void {
static setLogLevel(level: LogLevelString): void {
validateExactNumberOfArgs('Firestore.setLogLevel', arguments, 1);
validateArgType('Firestore.setLogLevel', 'non-empty string', 1, level);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this, you may want to call https://osscs.corp.google.com/firebase-sdk/firebase-js-sdk/+/master:packages/firestore/src/util/input_validation.ts;l=303?q=validate%20enum&ss=firebase-sdk%2Ffirebase-js-sdk

If you don't validate the enum constant here, setLogLevel sets the log level to undefined.

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.

wu-hui added 2 commits May 28, 2020 10:21
@wu-hui wu-hui assigned schmidt-sebastian and unassigned hsubox76 and wu-hui May 29, 2020
@@ -37,7 +37,7 @@ export interface PersistenceSettings {
experimentalTabSynchronization?: boolean;
}

export type LogLevel = 'debug' | 'error' | 'silent';
export type LogLevel = 'debug' | 'error' | 'silent' | 'warn';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not want to expose all levels? You are missing verbose and info.

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.

@@ -28,8 +28,8 @@ export function getLogLevel(): LogLevel {
return logClient.logLevel;
}

export function setLogLevel(newLevel: LogLevel): void {
logClient.logLevel = newLevel;
export function setLogLevel(newLevel: LogLevelString | LogLevel): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can probably drop LogLevel as an input 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.

async_queue.test.ts calls getLogLevel() before changing it, then set the saved log level back when test is done. https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/test/unit/util/async_queue.test.ts#L84

It's only testing code, but i think it does no harm to keep it anyways?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.

This could also be fixed by returning the LogLevelString from getLogLevel() and calling setLogLevel('silent') instead of setLogLevel(LogLevel.SILENT). We can leave as is though.

@wu-hui wu-hui assigned schmidt-sebastian and unassigned wu-hui May 29, 2020
}
validateStringEnum(
'setLogLevel',
['debug', 'error', 'silent', 'warn'],
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 'verbose' and 'info' here as well.

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.

@@ -28,8 +28,8 @@ export function getLogLevel(): LogLevel {
return logClient.logLevel;
}

export function setLogLevel(newLevel: LogLevel): void {
logClient.logLevel = newLevel;
export function setLogLevel(newLevel: LogLevelString | LogLevel): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.

This could also be fixed by returning the LogLevelString from getLogLevel() and calling setLogLevel('silent') instead of setLogLevel(LogLevel.SILENT). We can leave as is though.

@wu-hui wu-hui merged commit 31f7afc into master Jun 1, 2020
Comment on lines +40 to +46
export type LogLevel =
| 'debug'
| 'error'
| 'silent'
| 'warn'
| 'info'
| 'verbose';
Copy link
Member

Choose a reason for hiding this comment

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

Are you planning to make it public? If so, you have to update packages/firebase/index.d.ts

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Pinged on chat

@firebase firebase locked and limited conversation to collaborators Jul 2, 2020
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.

5 participants