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.
Analyze your WhatsApp group chats with ZapZipped! Get fun stats, awards, and a year-end recap to celebrate. All your stats and awards in WhatsApp wrap...
Splotch converts any process or idea from text into a clear, easy-to-follow diagram in seconds. Simplify your workflow and try our 7-day free trial to...
Supercharge Your BlueSky Experience