From 28d7d48907efe7da3f023b1810692efdf18fba93 Mon Sep 17 00:00:00 2001 From: Gregory Kim Date: Thu, 21 Dec 2023 12:08:39 -0700 Subject: [PATCH 1/3] Add New Relic Agent Transport entry. --- docs/transports.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/transports.md b/docs/transports.md index 3ad2466d1..3a454de60 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -49,6 +49,7 @@ there are additional transports written by * [Logz.io](#logzio-transport) * [Mail](#mail-transport) * [Newrelic](#newrelic-transport) (errors only) + * [New Relic](#new-relic-agent-transport) * [Papertrail](#papertrail-transport) * [PostgresQL](#postgresql-transport) * [Pusher](#pusher-transport) @@ -656,6 +657,25 @@ The Newrelic transport will send your errors to newrelic and accepts the follwin If `env` is either 'dev' or 'test' the lib will _not_ load the included newrelic module saving devs from anoying errors ;) +### New Relic Agent Transport + +[winston-newrelic-agent-transport][47] is a New Relic transport that leverages the New Relic agent: + +``` js +import winston from 'winston' +import NewrelicTransport from 'winston-newrelic-agent-transport' + +const options = {} + +const logger = winston.createLogger({ + transports: [ + new NewrelicTransport(options) + ] +}) +``` + +The New Relic agent typically automatically sends Winston logs to New Relic when using CommonJS. With CommonJS no additional transport should be needed. However, when using ECMAScript modules, the automatic sending of logs can with certain coding patterns not work. This transport leverages the New Relic agent to send logs to New Relic for the times when automatic log sending is not working. + ### Papertrail Transport [winston-papertrail][27] is a Papertrail transport: @@ -1010,3 +1030,4 @@ That's why we say it's a logger for just about everything [44]: https://github.com/Quintinity/humio-winston [45]: https://github.com/datalust/winston-seq [46]: https://github.com/arpad1337/winston-console-transport-in-worker +[47]: https://github.com/kimnetics/winston-newrelic-agent-transport From 64982090c018e1e4f6c42f230609f808b80aeed7 Mon Sep 17 00:00:00 2001 From: Gregory Kim Date: Thu, 21 Dec 2023 12:17:45 -0700 Subject: [PATCH 2/3] Add description of options. --- docs/transports.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/transports.md b/docs/transports.md index 3a454de60..eabb3eac9 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -676,6 +676,10 @@ const logger = winston.createLogger({ The New Relic agent typically automatically sends Winston logs to New Relic when using CommonJS. With CommonJS no additional transport should be needed. However, when using ECMAScript modules, the automatic sending of logs can with certain coding patterns not work. This transport leverages the New Relic agent to send logs to New Relic for the times when automatic log sending is not working. +Options: +* __level__: The Winston logging level to use as the maximum level of messages that the transport will log. +* __rejectCriteria__: The rejectCriteria option allows you to specify an array of regexes that will be matched against either the Winston info object or log message to determine whether or not a log message should be rejected and not logged to New Relic. + ### Papertrail Transport [winston-papertrail][27] is a Papertrail transport: From 2f1e16d58b82f43e4fa548a79f79bbd7d74e3d18 Mon Sep 17 00:00:00 2001 From: Gregory Kim Date: Fri, 2 Feb 2024 17:00:40 -0700 Subject: [PATCH 3/3] Adjust code example style to better match other transports. Adjust description to match transport repo changes. --- docs/transports.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/transports.md b/docs/transports.md index eabb3eac9..417ae824f 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -665,20 +665,18 @@ If `env` is either 'dev' or 'test' the lib will _not_ load the included newrelic import winston from 'winston' import NewrelicTransport from 'winston-newrelic-agent-transport' -const options = {} +const logger = winston.createLogger() -const logger = winston.createLogger({ - transports: [ - new NewrelicTransport(options) - ] -}) +const options = {} +logger.add(new NewrelicTransport(options)) ``` -The New Relic agent typically automatically sends Winston logs to New Relic when using CommonJS. With CommonJS no additional transport should be needed. However, when using ECMAScript modules, the automatic sending of logs can with certain coding patterns not work. This transport leverages the New Relic agent to send logs to New Relic for the times when automatic log sending is not working. +The New Relic agent typically automatically forwards Winston logs to New Relic when using CommonJS. With CommonJS no additional transport should be needed. However, when using ECMAScript modules, the automatic forwarding of logs can with certain coding patterns not work. If the New Relic agent is not automatically forwarding your logs, this transport provides a solution. Options: -* __level__: The Winston logging level to use as the maximum level of messages that the transport will log. -* __rejectCriteria__: The rejectCriteria option allows you to specify an array of regexes that will be matched against either the Winston info object or log message to determine whether or not a log message should be rejected and not logged to New Relic. + +* __level__ (optional): The Winston logging level to use as the maximum level of messages that the transport will log. +* __rejectCriteria__ (optional): The rejectCriteria option allows you to specify an array of regexes that will be matched against either the Winston info object or log message to determine whether or not a log message should be rejected and not logged to New Relic. ### Papertrail Transport