pino-logflare
Advanced tools
Comparing version 0.3.5 to 0.3.6-04275a27
@@ -9,2 +9,3 @@ "use strict"; | ||
var stream_1 = __importDefault(require("stream")); | ||
var utils_2 = require("./utils"); | ||
var createConsoleWriteStream = function (options) { | ||
@@ -20,2 +21,3 @@ var writeStream = new stream_1.default.Writable({ | ||
.map(utils_1.toLogEntry) | ||
.map(function (logEntry) { return utils_2.addLogflareTransformDirectives(logEntry, options); }) | ||
.map(JSON.stringify) | ||
@@ -22,0 +24,0 @@ .forEach(function (x) { |
@@ -17,3 +17,3 @@ "use strict"; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -29,3 +29,3 @@ return result; | ||
var parseJsonStream = streams.parseJsonStream(); | ||
var toLogEntryStream = streams.toLogEntryStream(); | ||
var toLogEntryStream = streams.toLogEntryStream(options); | ||
var batchStream = streams.batchStream(size); | ||
@@ -32,0 +32,0 @@ var writeStream = new logflare_transport_core_1.LogflareHttpClient(options).insertStream(); |
@@ -33,3 +33,4 @@ "use strict"; | ||
var logflareLogEvent = utils_1.formatPinoBrowserLogEvent(logEvent); | ||
client.postLogEvents([logflareLogEvent]); | ||
var maybeWithTransforms = utils_1.addLogflareTransformDirectives(logflareLogEvent, options); | ||
client.postLogEvents([maybeWithTransforms]); | ||
}; | ||
@@ -36,0 +37,0 @@ }; |
/// <reference types="node" /> | ||
import { LogflareUserOptionsI } from "logflare-transport-core"; | ||
declare function batchStream(size: number): any; | ||
declare function parseJsonStream(): import("stream").Transform; | ||
declare function toLogEntryStream(): import("stream").Transform; | ||
declare function toLogEntryStream(options: LogflareUserOptionsI): import("stream").Transform; | ||
export { batchStream, parseJsonStream, toLogEntryStream, }; |
@@ -25,6 +25,7 @@ "use strict"; | ||
exports.parseJsonStream = parseJsonStream; | ||
function toLogEntryStream() { | ||
function toLogEntryStream(options) { | ||
return through2_1.default.obj(function (chunk, enc, cb) { | ||
var entry = utils_1.toLogEntry(chunk); | ||
cb(null, entry); | ||
var maybeWithTransforms = utils_1.addLogflareTransformDirectives(entry, options); | ||
cb(null, maybeWithTransforms); | ||
}); | ||
@@ -31,0 +32,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import _ from "lodash"; | ||
import { LogflareUserOptionsI } from "logflare-transport-core"; | ||
interface pinoBrowserLogEventI { | ||
@@ -20,10 +20,4 @@ ts: number; | ||
}; | ||
declare function toLogEntry(item: Record<string, any>): { | ||
metadata: { | ||
context: _.Dictionary<any>; | ||
level: string; | ||
}; | ||
message: any; | ||
timestamp: any; | ||
}; | ||
export { toLogEntry, formatPinoBrowserLogEvent, pinoBrowserLogEventI }; | ||
declare function addLogflareTransformDirectives(item: Record<string, any>, options: LogflareUserOptionsI): Record<string, any>; | ||
declare function toLogEntry(item: Record<string, any>): Record<string, any>; | ||
export { toLogEntry, formatPinoBrowserLogEvent, pinoBrowserLogEventI, addLogflareTransformDirectives, }; |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatPinoBrowserLogEvent = exports.toLogEntry = void 0; | ||
exports.addLogflareTransformDirectives = exports.formatPinoBrowserLogEvent = exports.toLogEntry = void 0; | ||
var lodash_1 = __importDefault(require("lodash")); | ||
@@ -46,3 +46,3 @@ var lodash_2 = require("lodash"); | ||
level: level, | ||
browser: true | ||
browser: true, | ||
}; | ||
@@ -60,2 +60,12 @@ var bindingsAndMessages = bindings.concat(objMessages); | ||
exports.formatPinoBrowserLogEvent = formatPinoBrowserLogEvent; | ||
function addLogflareTransformDirectives(item, options) { | ||
var _a; | ||
if ((_a = options === null || options === void 0 ? void 0 : options.transforms) === null || _a === void 0 ? void 0 : _a.numbersToFloats) { | ||
return __assign(__assign({}, item), { "@logflareTransformDirectives": { numbersToFloats: true } }); | ||
} | ||
else { | ||
return item; | ||
} | ||
} | ||
exports.addLogflareTransformDirectives = addLogflareTransformDirectives; | ||
function toLogEntry(item) { | ||
@@ -70,3 +80,12 @@ var status = levelToStatus(item.level); | ||
var timestamp = item.time || new Date().getTime(); | ||
var cleanedItem = lodash_1.default.omit(item, ["time", "level", "msg", "hostname", "service", "pid", "stack", "type"]); | ||
var cleanedItem = lodash_1.default.omit(item, [ | ||
"time", | ||
"level", | ||
"msg", | ||
"hostname", | ||
"service", | ||
"pid", | ||
"stack", | ||
"type", | ||
]); | ||
var context = lodash_1.default.pickBy({ host: host, service: service, pid: pid, stack: stack, type: type }, function (x) { return x; }); | ||
@@ -73,0 +92,0 @@ return { |
{ | ||
"name": "pino-logflare", | ||
"version": "0.3.5", | ||
"version": "0.3.6-04275a27", | ||
"description": "A transport for Pino that sends messages to Logflare", | ||
@@ -60,3 +60,3 @@ "homepage": "https://github.com/logflare/pino-logflare", | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"axios": "^0.21.1", | ||
"batch2": "^1.0.6", | ||
@@ -66,3 +66,3 @@ "commander": "^5.0.0", | ||
"lodash": "^4.17.15", | ||
"logflare-transport-core": "^0.2.4", | ||
"logflare-transport-core": "^0.2.5", | ||
"pino": "^6.3.2", | ||
@@ -75,3 +75,3 @@ "pumpify": "^2.0.1", | ||
"prettier": { | ||
"singleQuote": true, | ||
"singleQuote": false, | ||
"semi": false, | ||
@@ -87,2 +87,2 @@ "arrowParens": "always" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26960
361
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)
Updatedaxios@^0.21.1