1 | # @firebase/logger
|
2 |
|
3 | This package serves as the base of all logging in the JS SDK. Any logging that
|
4 | is intended to be visible to Firebase end developers should go through this
|
5 | module.
|
6 |
|
7 | ## Basic Usage
|
8 |
|
9 | Firebase components should import the `Logger` class and instantiate a new
|
10 | instance by passing a component name (e.g. `@firebase/<COMPONENT>`) to the
|
11 | constructor.
|
12 |
|
13 | _e.g._
|
14 |
|
15 | ```typescript
|
16 | import { Logger } from '@firebase/logger';
|
17 |
|
18 | const logClient = new Logger(`@firebase/<COMPONENT>`);
|
19 | ```
|
20 |
|
21 | Each `Logger` instance supports 5 log functions each to be used in a specific
|
22 | instance:
|
23 |
|
24 | - `debug`: Internal logs; use this to allow developers to send us their debug
|
25 | logs for us to be able to diagnose an issue.
|
26 | - `log`: Use to inform your user about things they may need to know.
|
27 | - `info`: Use if you have to inform the user about something that they need to
|
28 | take a concrete action on. Once they take that action, the log should go away.
|
29 | - `warn`: Use when a product feature may stop functioning correctly; unexpected
|
30 | scenario.
|
31 | - `error`: Only use when user App would stop functioning correctly - super rare!
|
32 |
|
33 | ## Log Format
|
34 |
|
35 | Each log will be formatted in the following manner:
|
36 |
|
37 | ```typescript
|
38 | `[${new Date()}] ${COMPONENT_NAME}: ${...args}`
|
39 | ```
|
40 |
|