Socket
Socket
Sign inDemoInstall

winston-newrelic-logs-transport

Package Overview
Dependencies
15
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

.github/workflows/check.yml

32

dist/index.js

@@ -9,26 +9,26 @@ "use strict";

const triple_beam_1 = require("triple-beam");
class Newrelic extends winston_transport_1.default {
constructor(options = { licenseKey: '', apiUrl: '' }) {
class WinstonNewrelicLogsTransport extends winston_transport_1.default {
constructor(options) {
var _a;
super();
this.axiosClient = axios_1.default.create({
baseURL: options.apiUrl,
timeout: 5000,
headers: {
'X-License-Key': options.licenseKey,
'Content-Type': 'application/json'
}
});
this.axiosClient = axios_1.default.create(Object.assign(Object.assign({ timeout: 5000 }, options.axiosOptions), { baseURL: options.apiUrl, headers: Object.assign(Object.assign({}, (_a = options.axiosOptions) === null || _a === void 0 ? void 0 : _a.headers), { "X-License-Key": options.licenseKey, "Content-Type": "application/json" }) }));
}
log(info, callback) {
setImmediate(() => this.emit('logged', info));
this.axiosClient.post('/log/v1', {
this.axiosClient
.post("/log/v1", {
timestamp: Date.now(),
message: info[triple_beam_1.MESSAGE],
logtype: info[triple_beam_1.LEVEL]
logtype: info[triple_beam_1.LEVEL],
})
.then(() => {
this.emit("logged", info);
callback(null);
})
.catch((err) => {
this.emit("error", err);
callback(err);
});
callback();
}
}
exports.default = Newrelic;
;
exports.default = WinstonNewrelicLogsTransport;
//# sourceMappingURL=index.js.map

@@ -1,37 +0,57 @@

import axios, { AxiosInstance } from 'axios';
import TransportStream from 'winston-transport';
import { LEVEL, MESSAGE } from 'triple-beam';
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
import TransportStream from "winston-transport";
import { LEVEL, MESSAGE } from "triple-beam";
export interface WinstonNewrelicLogsTransportOptions {
licenseKey: string;
apiUrl: string;
axiosOptions?: AxiosRequestConfig;
}
/**
* Transport for reporting errors to newrelic.
* @type {Newrelic}
*
* @type {WinstonNewrelicLogsTransport}
* @extends {TransportStream}
*/
export default class Newrelic extends TransportStream {
axiosClient: AxiosInstance;
export default class WinstonNewrelicLogsTransport extends TransportStream {
axiosClient: AxiosInstance;
constructor(options = { licenseKey: '', apiUrl: '' }) {
super();
constructor(options: WinstonNewrelicLogsTransportOptions) {
super();
this.axiosClient = axios.create({
baseURL: options.apiUrl,
timeout: 5000,
headers: {
'X-License-Key': options.licenseKey,
'Content-Type': 'application/json'
}
});
}
this.axiosClient = axios.create({
timeout: 5000,
...options.axiosOptions,
baseURL: options.apiUrl,
headers: {
...options.axiosOptions?.headers,
"X-License-Key": options.licenseKey,
"Content-Type": "application/json",
},
});
}
log(info: { [x in symbol]: string; }, callback: () => void) {
setImmediate(() => this.emit('logged', info));
log(info: { [x in symbol]: string }, callback: (error?: Error) => void) {
// The implementation of log callbacks isn't documented and the exported type
// definitions appear to be wrong too. This implementation has been compied
// https://github.com/winstonjs/winston-mongodb/blob/master/lib/winston-mongodb.js#L229-L235
// However I don't know what the second argument for callback is supposed to
// indicate.
this.axiosClient.post('/log/v1', {
timestamp: Date.now(),
message: info[MESSAGE],
logtype: info[LEVEL]
});
callback();
}
};
this.axiosClient
.post("/log/v1", {
timestamp: Date.now(),
message: info[MESSAGE],
logtype: info[LEVEL],
})
.then(() => {
this.emit("logged", info);
callback(null);
})
.catch((err) => {
this.emit("error", err);
callback(err);
});
}
}
{
"name": "winston-newrelic-logs-transport",
"version": "1.0.0",
"version": "1.1.0",
"description": "NewRelic Logs API Transport for Winston",

@@ -14,14 +14,15 @@ "main": "dist/index.js",

"prepublish": "tsc",
"start": "tsc && node dist/app.js",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "vitest"
},
"dependencies": {
"axios": "^0.21.1",
"logform": "^2.5.1",
"winston-transport": "^4.2.0"
},
"devDependencies": {
"@types/triple-beam": "^1.3.2",
"axios": "^0.21.1",
"newrelic": "^7.1.0",
"tslint": "^6.1.3",
"typescript": "^4.1.3",
"winston": "^3.0.0",
"winston-transport": "^4.2.0"
"typescript": "^4.9.5",
"vitest": "^0.29.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc