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.
Hire the AI Agent who writes and posts articles on your WP site(s). Automate SEO-optimized posts creation & publishing to engage, rank, & convert at s...
Remember your book, podcast, and article notes using science-backed methods like spaced repetition via email.
StoreLauncher is an AI Shopify store builder that helps entrepreneurs and small businesses create high-converting, ready-to-sell e-commerce stores eff...