Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loglayer/loglayer
Standardizes logging across multiple Javascript logging libraries, providing a consistent way to specify context, metadata, and errors.
https://github.com/loglayer/loglayer
abstraction bunyan consula electron javascript log log4js log4js-node logger logging logging-library nodejs pino roarr signale standard structure typescript winston
Last synced: 2 days ago
JSON representation
Standardizes logging across multiple Javascript logging libraries, providing a consistent way to specify context, metadata, and errors.
- Host: GitHub
- URL: https://github.com/loglayer/loglayer
- Owner: loglayer
- License: mit
- Created: 2021-11-25T23:24:36.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-12-30T22:03:46.000Z (11 days ago)
- Last Synced: 2025-01-01T20:06:45.066Z (9 days ago)
- Topics: abstraction, bunyan, consula, electron, javascript, log, log4js, log4js-node, logger, logging, logging-library, nodejs, pino, roarr, signale, standard, structure, typescript, winston
- Language: TypeScript
- Homepage:
- Size: 975 KB
- Stars: 77
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# LogLayer
[![NPM version](https://img.shields.io/npm/v/loglayer.svg?style=flat-square)](https://www.npmjs.com/package/loglayer)
[![NPM Downloads](https://img.shields.io/npm/dm/loglayer)](https://www.npmjs.com/package/loglayer)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)`loglayer` is a unified logger that routes logs to various logging libraries and cloud providers while providing a fluent API for specifying log messages, metadata and errors.
- For full documentation, read the [docs](https://loglayer.dev).
- [Older 4.x documentation](https://github.com/loglayer/loglayer/tree/4.x)```javascript
// Example using the Pino logging library with LogLayer
import { LogLayer } from 'loglayer';
import { pino } from 'pino';
import { PinoTransport } from '@loglayer/transport-pino';
import { redactionPlugin } from '@loglayer/plugin-redaction';const log = new LogLayer({
// Multiple loggers can also be used at the same time.
transport: new PinoTransport({
logger: pino()
}),
// Plugins can be created to modify log data before it's shipped to your logging library.
plugins: [
redactionPlugin({
paths: ['password'],
censor: '[REDACTED]',
}),
],
})log.withPrefix("[my-app]")
.withMetadata({ some: 'data', password: 'my-pass' })
.withError(new Error('test'))
.info('my message')
``````json5
{
"level":30,
"time":1735857465669,
"msg":"[my-app] my message",
// The placement of these fields are also configurable!
"password":"[REDACTED]",
"some":"data",
"err":{
"type":"Error",
"message":"test",
"stack":"Error: test\n ..."
}
}
```## Development Setup
This is a monorepo using [`pnpm`](https://pnpm.io/installation) for package management and [`turbo`](https://turbo.build/repo/docs/getting-started/installation) for build orchestration.
If you're looking to contribute or work with the source code, follow these steps:1. Clone the repository
2. Install dependencies:
```bash
pnpm install
```
3. Build all packages:
```bash
turbo build
```
## Running TestsTo run tests for all packages, use the following command:
```bash
turbo test
```## Viewing docs
The docs use [vitepress](https://vitepress.dev/). To view the docs locally, run:
```bash
turbo docs:dev
```## Project Structure
```
loglayer/
├── docs/ # Documentation (vitepress)
├── packages/
│ ├── core/ # Core packages
│ │ ├── loglayer/ # Main LogLayer implementation
│ │ ├── plugin/ # Plugin system core
│ │ ├── transport/ # Transport system core
│ │ ├── shared/ # Shared utilities and types
│ │ └── tsconfig/ # Shared TypeScript configurations
│ ├── transports/ # Official transport implementations
│ └── plugins/ # Official plugins
```## Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
## Documentation
For detailed documentation, visit [https://loglayer.dev](https://loglayer.dev)