LogLayer is a unified layer on top of popular JavaScript logging libraries, providing a consistent logging experience across various environments. Its primary goal is to simplify the process of integrating multiple logging providers into a single application.
LogLayer offers structured logging capabilities through its fluid API. This allows developers to easily add tags, metadata, and errors to their logs with minimal code changes.
The LogLayer plugin system enables users to switch between different logging providers without modifying their application code. Developers can start with console logging and then transition to another provider later on.
LogLayer's plugin system allows developers to customize every aspect of the logging pipeline, from log transformation and enrichment to filtering and aggregation.
LogLayer supports fan-out to multiple logging libraries and cloud providers simultaneously. This means that applications can seamlessly integrate with various logging solutions, such as DataDog and New Relic.
LogLayer integrates with a wide range of popular logging libraries and cloud providers, including:
import { LogLayer } from 'loglayer';
import { pino } from 'pino';
import { PinoTransport } from '@loglayer/transport-pino';
import { redactionPlugin } from '@loglayer/plugin-redaction';
const log = new LogLayer({
transport: new PinoTransport({
logger: pino()
}),
plugins: [
redactionPlugin({
paths: ['password'],
censor: '[REDACTED]',
})
]
});
log.withPrefix("[my-app]")
.withMetadata({ some: 'data', password: 'my-pass' })
.withError(new Error('test'))
.info('my message');
This code snippet demonstrates how to create a LogLayer instance with a Pino transport and apply a redaction plugin to the logs. The resulting log entry would look like this:
{
"level": 30,
"time": 1735857465669,
"msg": "[my-app] my message",
"password": "[REDACTED]",
"some": "data",
"err":{
"type": "Error",
"message": "test",
"stack": "Error: test\n ..."
}
}
By using LogLayer, developers can simplify the process of integrating multiple logging providers into their applications and ensure a consistent logging experience across different environments.
Supercharge sales enablement with intelligent, interactive demos that turn prospects into customers faster and more effectively.
BigScrubber is a Safari extension that fixes our YouTube experience. Heres how: It makes the PlayPause and Fullscreen buttons larger, so we wont misc...
Generate polls in seconds using AI, share them instantly, and gather responses in real-time.