-
Notifications
You must be signed in to change notification settings - Fork 935
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
Changes from 4 commits
74f3e84
db25c5f
8825bd5
7547bb2
d102dd1
e71188c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,8 +616,12 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService { | |
switch (getLogLevel()) { | ||
case LogLevel.DEBUG: | ||
return 'debug'; | ||
case LogLevel.ERROR: | ||
return 'error'; | ||
case LogLevel.SILENT: | ||
return 'silent'; | ||
case LogLevel.WARN: | ||
return 'warn'; | ||
default: | ||
// The default log level is error | ||
return 'error'; | ||
|
@@ -626,23 +630,13 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService { | |
|
||
static setLogLevel(level: firestore.LogLevel): void { | ||
validateExactNumberOfArgs('Firestore.setLogLevel', arguments, 1); | ||
validateArgType('Firestore.setLogLevel', 'non-empty string', 1, level); | ||
switch (level) { | ||
case 'debug': | ||
setLogLevel(LogLevel.DEBUG); | ||
break; | ||
case 'error': | ||
setLogLevel(LogLevel.ERROR); | ||
break; | ||
case 'silent': | ||
setLogLevel(LogLevel.SILENT); | ||
break; | ||
default: | ||
throw new FirestoreError( | ||
Code.INVALID_ARGUMENT, | ||
'Invalid log level: ' + level | ||
); | ||
} | ||
validateStringEnum( | ||
'setLogLevel', | ||
['debug', 'error', 'silent', 'warn'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
1, | ||
level | ||
); | ||
setLogLevel(level); | ||
} | ||
|
||
// Note: this is not a property because the minifier can't work correctly with | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import { Logger, LogLevel } from '@firebase/logger'; | ||
import { Logger, LogLevel, LogLevelString } from '@firebase/logger'; | ||
import { SDK_VERSION } from '../core/version'; | ||
import { PlatformSupport } from '../platform/platform'; | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. You can probably drop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. async_queue.test.ts calls 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 commentThe reason will be displayed to describe this comment to others. Learn more. SGTM. This could also be fixed by returning the LogLevelString from |
||
logClient.setLogLevel(newLevel); | ||
} | ||
|
||
export function logDebug(msg: string, ...obj: unknown[]): void { | ||
|
@@ -46,6 +46,13 @@ export function logError(msg: string, ...obj: unknown[]): void { | |
} | ||
} | ||
|
||
export function logWarn(msg: string, ...obj: unknown[]): void { | ||
if (logClient.logLevel <= LogLevel.WARN) { | ||
const args = obj.map(argToString); | ||
logClient.warn(`Firestore (${SDK_VERSION}): ${msg}`, ...args); | ||
} | ||
} | ||
|
||
/** | ||
* Converts an additional log parameter to a string representation. | ||
*/ | ||
|
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
andinfo
.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.