-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1,75 @@ | ||
# utils | ||
Shared utility libraries and functions for Nexus Mutual repositories | ||
# Nexus Mutual Utilities | ||
|
||
## Table of Contents | ||
|
||
- [Nexus Mutual Utilities](#nexus-mutual-utilities) | ||
- [Table of Contents](#table-of-contents) | ||
- [Installation](#installation) | ||
- [Log Level Library](#log-level-library) | ||
- [Usage](#usage) | ||
- [Importing the Log Level Utility](#importing-the-log-level-utility) | ||
- [Usage in Code](#usage-in-code) | ||
- [Log Levels](#log-levels) | ||
- [Development](#development) | ||
- [Install Dependencies](#install-dependencies) | ||
- [Build Locally](#build-locally) | ||
|
||
## Installation | ||
|
||
Install the package using npm: | ||
|
||
```bash | ||
npm install @nexusmutual/utils | ||
``` | ||
|
||
## Log Level Library | ||
|
||
The `log-level` library provides a utility to manage and handle logging levels in your application. | ||
|
||
### Usage | ||
|
||
#### Importing the Log Level Utility | ||
|
||
```typescript | ||
import { setLogLevel } from '@nexusmutual/utils'; | ||
``` | ||
|
||
#### Usage in Code | ||
|
||
Call `setLogLevel` at the start of the entry point to configure log levels. | ||
|
||
```typescript | ||
setLogLevel(process.env.LOG_LEVEL); | ||
``` | ||
|
||
### Log Levels | ||
|
||
The `log-level` utility supports the following logging levels (case insensitive) and ordered from the most verbose to the least verbose logging: | ||
|
||
- `all`: Enables logging of all levels. | ||
- `trace`: Enables logging of `trace`, `debug`, `info`, `warn`, and `error`. | ||
- `debug`: Enables logging of `debug`, `info`, `warn`, and `error`. Disables `trace`. | ||
- `info`: Enables logging of `info`, `warn`, and `error`. Disables `trace` and `debug`. | ||
- `warn`: Enables logging of `warn` and `error`. Disables `trace`, `debug`, and `info`. | ||
- `error`: Enables logging of `error` only. Disables `trace`, `debug`, `info` and `warn`. | ||
- `silence`: Disables all logging output. | ||
|
||
## Development | ||
|
||
### Install Dependencies | ||
|
||
Install all dependencies with: | ||
|
||
```bash | ||
npm ci | ||
``` | ||
|
||
### Build Locally | ||
|
||
To build the library locally, run: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
This will compile the TypeScript code into JavaScript in the `dist` folder. |