@rnx-kit/console
Version:
Simple console logger
41 lines (31 loc) • 1.72 kB
Markdown
# -kit/console
[](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml)
[](https://www.npmjs.com/package/@rnx-kit/console)
`-kit/console` is a simple console logger that is a subset of the logger in
[`-native-community/cli-tools`](https://github.com/react-native-community/cli/blob/6615eb30f37bec5bb25acc066c849c4aa2d8a4cd/packages/tools/src/logger.ts).
It is used by
[Metro plugins](https://github.com/microsoft/rnx-kit/tree/main/packages) to
ensure that log lines are consistent with `-native-community/cli`.
Ideally, we should be using the reporter that is passed to Metro but we don't
have access to it from the `customSerializer` hook. The next best thing would be
to use `-native-community/cli-tools` but it includes a bunch of other
tools and we cannot take a dependency on any single version since we need to
support multiple versions of `react-native` (and hence multiple versions of
`-native-community/cli-tools`).
Other libraries, such as
[`just-task-logger`](https://github.com/microsoft/just/tree/master/packages/just-task-logger),
were also considered. However, the purpose of this package is to match with the
output of `-native-community/cli`. `just-task-logger` in particular uses
its own colour scheme and doesn't allow configuring them to match the colour
scheme.
## Install
```sh
yarn add -kit/console --dev
```
## Usage
```ts
import { error, info, warn } from "@rnx-kit/console";
error("This is an error message");
info("This is an informational message");
warn("This is a warning");
```