Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@mkkr/winston-papertrail-transport
Advanced tools
A Papertrail transport for winston ^3.0.0. Heavily inspired by and borrows from winston-papertrail and winston-syslog
$ curl http://npmjs.org/install.sh | sh
$ npm install winston
$ npm install winston-papertrail-transport
To create the transport, simply import the transport and create an instance
import * as winston from 'winston';
import { PapertrailTransport } from 'winston-papertrail-transport';
const papertrailTransport = new PapertrailTransport({
host: 'logs.papertrail.com',
port: 12345,
});
const logger = winston.createLogger({
transports: [papertrailTransport],
});
The following options are required for logging to Papertrail:
The following options are optional
false
.os.hostname()
.default
.daemon
.false
.true
.5
.25
.1000
.60000
.To close the connection, you can use the close()
function on the transport, e.g. papertrailTransport.close()
.
The PapertrailConnection
class which handles the connection and reconnection to Papertrail can be accessed via the connection
field on the transport, e.g. papertrailTransport.connection
.
PapertrailConnection
extends EventEmitter
and allows the user to listen to connect
and error
events, e.g.
papertrailTransport.connection.on('error', error => {
console.error('Error recieved from PapertrailTransport: ' + error.message);
});
papertrailTransport.connection.on('connect', event => {
console.log(event);
});
Here is an example on how the papertrail transport can be used together with the console transport in a typescript express app. The example also modifies some settings to yield a meaningful log line in Papertrail.
import * as packageFile from './package.json';
import * as winston from 'winston';
import expressWinston from 'express-winston';
import { PapertrailTransport } from 'winston-papertrail-transport';
const hostname = `${packageFile.name}:${process.env.NODE_ENV}`;
const container = new winston.Container();
function getConfig(program: string) {
const transports = [];
const consoleTransport = new winston.transports.Console();
transports.push(consoleTransport);
const papertrailTransport = new PapertrailTransport({
host: 'logs.papertrailapp.com',
port: 1234,
hostname: hostname,
program,
});
transports.push(papertrailTransport);
return {
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple(),
winston.format.printf(({ level, message }) => `${level} ${message}`)
),
transports,
};
}
export function newLogger(program: string) {
return container.add(program, getConfig(program));
}
export const expressLogger = expressWinston.logger({
...getConfig('router'),
meta: false,
metaField: null,
expressFormat: true,
colorize: true,
});
express-logger
will print
Jul 09 12:55:43 exampleApp:development router info GET / 304 9ms
newLogger('server').info('listening')
will print
Jul 09 12:56:35 exampleApp:development server info listening
FAQs
A Papertrail transport for Winston 3
We found that @mkkr/winston-papertrail-transport demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.