Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vexell/nodejs-lsd-logger
Node.js logger for LSD streaming deamon
https://github.com/vexell/nodejs-lsd-logger
log logger logging logging-library logs lsd
Last synced: 4 days ago
JSON representation
Node.js logger for LSD streaming deamon
- Host: GitHub
- URL: https://github.com/vexell/nodejs-lsd-logger
- Owner: VeXell
- Created: 2023-02-11T22:11:18.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T11:51:45.000Z (5 days ago)
- Last Synced: 2024-11-14T12:35:29.917Z (5 days ago)
- Topics: log, logger, logging, logging-library, logs, lsd
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js logger for LSD Server [![npm version](https://badge.fury.io/js/nodejs-lsd-logger.svg)](https://www.npmjs.com/package/nodejs-lsd-logger)
Node.js logger for [LSD streaming deamon](https://github.com/badoo/lsd)
Logger writes to small files, depending on current time.
```
lsd_dir/category_name/year|month|day|hour|minute.log
// for example
lsd_dir/category_name/202302121626.log
```All messages written to these files less than PIPE_BUF (4k in Linux by default).
If you write lines larger than PIPE_BUF, logger creates another file with postfix `_big` (for example `lsd_dir/category_name/202302121626_big.log`) and flock(LOCK_EX) for writing.
## Install
```bash
npm install nodejs-lsd-logger
```## Usage
Import `writeLog` or `writeJson` function from the library and use it to write data.
Both functions return Promise and you can catch logging errors.```javascript
// import { writeLog } from 'nodejs-lsd-logger';
import { writeJson } from 'nodejs-lsd-logger';writeJson('path/to/lsd_dir', {
string: 'string',
number: 123,
}).catch((error) => {
console.error(error);
});
```