-
Notifications
You must be signed in to change notification settings - Fork 934
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
Conversation
There was a problem hiding this 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
Binary Size ReportAffected SDKs
Test Logs |
6722078
to
db25c5f
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
packages/firestore/src/util/log.ts
Outdated
import { SDK_VERSION } from '../core/version'; | ||
import { PlatformSupport } from '../platform/platform'; | ||
|
||
export { LogLevel }; | ||
export { LogLevel, LogLevelString }; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
# Conflicts: # packages/logger/src/logger.ts
packages/firestore-types/index.d.ts
Outdated
@@ -37,7 +37,7 @@ export interface PersistenceSettings { | |||
experimentalTabSynchronization?: boolean; | |||
} | |||
|
|||
export type LogLevel = 'debug' | 'error' | 'silent'; | |||
export type LogLevel = 'debug' | 'error' | 'silent' | 'warn'; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
} | ||
validateStringEnum( | ||
'setLogLevel', | ||
['debug', 'error', 'silent', 'warn'], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
export type LogLevel = | ||
| 'debug' | ||
| 'error' | ||
| 'silent' | ||
| 'warn' | ||
| 'info' | ||
| 'verbose'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinged on chat
b/155897356