Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedromsilvapt/clui-logger
Easy to use logger for both small and serious apps that writes both to the terminal and to files
https://github.com/pedromsilvapt/clui-logger
Last synced: 11 days ago
JSON representation
Easy to use logger for both small and serious apps that writes both to the terminal and to files
- Host: GitHub
- URL: https://github.com/pedromsilvapt/clui-logger
- Owner: pedromsilvapt
- Created: 2019-02-28T10:25:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T20:26:59.000Z (over 1 year ago)
- Last Synced: 2024-12-02T04:29:15.803Z (about 1 month ago)
- Language: TypeScript
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# clui-logger
> Easy to use logger for both small and serious apps that writes both to the terminal and to files## Installation
```shell
npm install --save clui-logger
```## Usage
```typescript
import { Logger, MultiBackend, ConsoleBackend, FileBackend } from 'clui-logger';const logger = new Logger( new MultiBackend( [
new ConsoleBackend(),
new FileBackend( 'test/log.log' )
] ) );// Any type of log can have a payload
logger.debug( 'Debug log message' );
logger.info( 'Info log message' );
logger.warn( 'Warn log message' );
logger.error( 'Error log message' );
logger.fatal( 'Fatal error with a payload', new Error() );logger.service( 'clui-logger' ).info( 'Prefixed info message' );
// Create an auto-updating log message: on the console rewrites the previous line, and on a file just appends the new message
const live = logger.live();live.info( 'Progress 0/3' );
live.info( 'Progress 1/3' );
live.info( 'Progress 2/3' );
live.info( 'Progress 3/3' );logger.shared().info( 'clui-logger/shared', 'Shared loggers can have variable prefixes' );
logger.shared().info( 'clui-logger', 'A different prefix' );// Service loggers can create a hierarchy
logger.service( 'clui-logger' ).service( 'shared' ).info( 'This log is associated with the service clui-logger/shared' );
```