https://github.com/wolfchamane/amjs-logger
Handles log/trace/debug information
https://github.com/wolfchamane/amjs-logger
logs nodejs utils
Last synced: 22 days ago
JSON representation
Handles log/trace/debug information
- Host: GitHub
- URL: https://github.com/wolfchamane/amjs-logger
- Owner: Wolfchamane
- License: mit
- Created: 2019-07-22T07:15:58.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T05:01:43.000Z (over 3 years ago)
- Last Synced: 2025-10-11T14:22:35.483Z (8 months ago)
- Topics: logs, nodejs, utils
- Language: JavaScript
- Size: 639 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @amjs/logger 0.1.0
   
> Handles log/trace/debug information
## Installation
```bash
$ npm i @amjs/logger
```
## Usage
#### Default use
```javascript
const AmjsLogger = require('@amjs/logger');
const logger = new AmjsLogger();
logger.log('My log message is {{info}}', { info : 'logged!' }); //*
```
_*: Available methods are: 'log', 'error', 'debug', 'warn' and 'info'_
#### Stacked messages:
In this way of behaviour, messages can be stacked into a pile and through method __dump__ will be written into log file.
```javascript
const AmjsLogger = require('@amjs/logger');
const logger = new AmjsLogger({ stack : true });
logger.log('My log message');
logger.error('My error message');
logger.debug('My debug message');
logger.warn('My warning message');
logger.info('My info message');
logger.dump();
```
## Configuration
__@amjs/logger__ accepts following configuration options:
| Option | Description | Type | Default |
|:---:|:--- |:---:|:--- |
| date | Log traces fixed date | String | Instance creation date, as ISO string |
| destFolder | Destination folder to write logFile | String | _".tmp"_ |
| logFile | File to write | String | _".tmp/{date}.log"_ |
| name | App that is running the logger | String | _"@amjs/logger"_ |
| template | Log record template | String | _"{{date}} {{name}} [{{level}}] {{message}}"_ |
| trace | Whether to log messages into console or not | Boolean | false |
| stack | Whether to stack messages or not | Boolean | false |
By default, all paths are relative to _@amsj/logger_ installation path.
_date_ configuration property __is ony used__ for creating log file, records will have their own timestamp.