Files
Josh CrowtherandGitHub b83a21a72a @firebase/logger (#473)
* Start work on @firebase/logger package

* Refactor to remove debug dep

* [AUTOMATED]: Prettier Code Styling

* [AUTOMATED]: License Headers

* Expose a LogHandler type

* Allow users to "silence" our logging

* Adding some comments

* Do @firebase/firestore integration

* Do @firebase/database integration

* [AUTOMATED]: Prettier Code Styling

* Refactor to propagate the default level if changed

* Add some basic tests

* [AUTOMATED]: Prettier Code Styling

* Feedback from @mikelehen and @schmidt-sebastian

Refactor to also log fatal issues

Refactor to not attempt to log if the level is invalid

Adding docs and more feedback

* [AUTOMATED]: Prettier Code Styling

* Fixing an error message

* Updating yarn.lock

* Address @mikelehen feedback

* [AUTOMATED]: Prettier Code Styling

* Refactor logClient.log -> logClient.debug

* Update deps

* More @mikelehen feedback

* Fixing comment

* Feedback from @schmidt-sebastian
2018-02-28 10:49:47 -08:00

1.2 KiB

@firebase/logger

This package serves as the base of all logging in the JS SDK. Any logging that is intended to be visible to Firebase end developers should go through this module.

Basic Usage

Firebase components should import the Logger class and instantiate a new instance by passing a component name (e.g. @firebase/<COMPONENT>) to the constructor.

e.g.

import { Logger } from '@firebase/logger';

const logClient = new Logger(`@firebase/<COMPONENT>`);

Each Logger instance supports 5 log functions each to be used in a specific instance:

  • debug: Internal logs; use this to allow developers to send us their debug logs for us to be able to diagnose an issue.
  • log: Use to inform your user about things they may need to know.
  • info: Use if you have to inform the user about something that they need to take a concrete action on. Once they take that action, the log should go away.
  • warn: Use when a product feature may stop functioning correctly; unexpected scenario.
  • error: Only use when user App would stop functioning correctly - super rare!

Log Format

Each log will be formatted in the following manner:

`[${new Date()}]  ${COMPONENT_NAME}: ${...args}`