-
Notifications
You must be signed in to change notification settings - Fork 937
Client logging API: methods for users to access the SDK's log messages #2434
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a6dad17
initial log work
hsubox76 6675b7c
[AUTOMATED]: Prettier Code Styling
hsubox76 4891391
Remove source for now
hsubox76 fd3fef0
Fix some lint issues
hsubox76 92ec763
Add logger dep
hsubox76 ae1f8a7
Refactor types, add doc comments.
hsubox76 5cb934a
[AUTOMATED]: Prettier Code Styling
hsubox76 43222eb
Add tests, fix types
hsubox76 c81e8d8
Fix lint
hsubox76 312c43c
Address documentation comments
hsubox76 249d256
Address some PR comments
hsubox76 9d8f2a5
Address more PR comments
hsubox76 8cc455b
Fix comment
hsubox76 7113302
Merge branch 'master' into ch-clientlog
hsubox76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Logger } from '@firebase/logger'; | ||
|
||
export const logger = new Logger('@firebase/analytics'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { FirebaseNamespace, VersionService } from '@firebase/app-types'; | ||
import { _FirebaseApp, _FirebaseNamespace } from '@firebase/app-types/private'; | ||
import { createFirebaseNamespace } from '../src/firebaseNamespace'; | ||
import { expect } from 'chai'; | ||
import { spy as Spy } from 'sinon'; | ||
import './setup'; | ||
import { Logger } from '@firebase/logger'; | ||
import { registerCoreComponents } from '../src/registerCoreComponents'; | ||
import { | ||
Component, | ||
ComponentType | ||
} from '@firebase/component'; | ||
|
||
declare module '@firebase/component' { | ||
interface NameServiceMapping { | ||
'vs1': VersionService; | ||
'vs2': VersionService; | ||
'test-shell': Promise<void>; | ||
} | ||
} | ||
|
||
describe('User Log Methods', () => { | ||
describe('Integration Tests', () => { | ||
let firebase: FirebaseNamespace; | ||
let result: any = null; | ||
const warnSpy = Spy(console, 'warn'); | ||
const infoSpy = Spy(console, 'info'); | ||
const logSpy = Spy(console, 'log'); | ||
|
||
beforeEach(() => { | ||
firebase = createFirebaseNamespace(); | ||
}); | ||
|
||
it(`respects log level set through firebase.setLogLevel()`, () => { | ||
firebase.initializeApp({}); | ||
registerCoreComponents(firebase); | ||
(firebase as _FirebaseNamespace).INTERNAL.registerComponent( | ||
new Component( | ||
'test-shell', | ||
async () => { | ||
const logger = new Logger('@firebase/logger-test'); | ||
logger.warn('hello'); | ||
expect(warnSpy.called).to.be.true; | ||
(firebase as _FirebaseNamespace).setLogLevel('warn'); | ||
logger.info('hi'); | ||
expect(infoSpy.called).to.be.false; | ||
logger.log('hi'); | ||
expect(logSpy.called).to.be.false; | ||
logSpy.resetHistory(); | ||
infoSpy.resetHistory(); | ||
(firebase as _FirebaseNamespace).setLogLevel('debug'); | ||
logger.info('hi'); | ||
expect(infoSpy.called).to.be.true; | ||
logger.log('hi'); | ||
expect(logSpy.called).to.be.true; | ||
}, | ||
ComponentType.PUBLIC | ||
) | ||
); | ||
return (firebase as any)['test-shell'](); | ||
}); | ||
|
||
it(`correctly triggers callback given to firebase.onLog()`, () => { | ||
// Note: default log level is INFO. | ||
firebase.initializeApp({}); | ||
registerCoreComponents(firebase); | ||
(firebase as _FirebaseNamespace).INTERNAL.registerComponent( | ||
new Component( | ||
'test-shell', | ||
async () => { | ||
const logger = new Logger('@firebase/logger-test'); | ||
(firebase as _FirebaseNamespace).onLog((logData) => { | ||
result = logData; | ||
}); | ||
logger.info('hi'); | ||
expect(result.level).to.equal('info'); | ||
expect(result.message).to.equal('hi'); | ||
expect(result.args).to.deep.equal(['hi']); | ||
expect(result.type).to.equal('@firebase/logger-test'); | ||
expect(infoSpy.called).to.be.true; | ||
}, | ||
ComponentType.PUBLIC | ||
) | ||
); | ||
return (firebase as any)['test-shell'](); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.