UNPKG

1.24 kBMarkdownView Raw
1# @firebase/logger
2
3This package serves as the base of all logging in the JS SDK. Any logging that
4is intended to be visible to Firebase end developers should go through this
5module.
6
7## Basic Usage
8
9Firebase components should import the `Logger` class and instantiate a new
10instance by passing a component name (e.g. `@firebase/<COMPONENT>`) to the
11constructor.
12
13_e.g._
14
15```typescript
16import { Logger } from '@firebase/logger';
17
18const logClient = new Logger(`@firebase/<COMPONENT>`);
19```
20
21Each `Logger` instance supports 5 log functions each to be used in a specific
22instance:
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
35Each log will be formatted in the following manner:
36
37```typescript
38`[${new Date()}] ${COMPONENT_NAME}: ${...args}`
39```
40