pino-logflare
Advanced tools
Comparing version 0.4.0 to 0.4.1-92ca7ee1
@@ -1,5 +0,5 @@ | ||
import { LogflareUserOptionsI } from "logflare-transport-core"; | ||
declare const createConsoleWriteStream: (options: LogflareUserOptionsI) => { | ||
import { Options } from "./httpStream"; | ||
declare const createConsoleWriteStream: (options: Options) => { | ||
write: (chunk: any) => void; | ||
}; | ||
export default createConsoleWriteStream; |
@@ -11,3 +11,3 @@ "use strict"; | ||
.map(function (chunkItem) { return JSON.parse(chunkItem); }) | ||
.map(utils_1.toLogEntry) | ||
.map(function (item) { return utils_1.handlePreparePayload(item, options); }) | ||
.map(function (logEntry) { | ||
@@ -14,0 +14,0 @@ return utils_2.addLogflareTransformDirectives(logEntry, options); |
import { LogflareUserOptionsI } from "logflare-transport-core"; | ||
interface Options extends LogflareUserOptionsI { | ||
export interface PayloadMeta { | ||
cleanedPayload: Record<string, any>; | ||
message?: string; | ||
level?: string; | ||
timestamp?: string; | ||
context: { | ||
host?: string; | ||
service?: string; | ||
pid?: string; | ||
stack?: string; | ||
type?: string; | ||
}; | ||
} | ||
export declare type PreparePayloadCallback = (payload: Record<string, any>, meta: PayloadMeta) => Record<string, any>; | ||
export interface Options extends LogflareUserOptionsI { | ||
size?: number; | ||
onPreparePayload?: PreparePayloadCallback; | ||
} | ||
declare function createWriteStream(options: Options): any; | ||
export default createWriteStream; |
/// <reference types="node" /> | ||
import { LogflareUserOptionsI } from "logflare-transport-core"; | ||
import { Options } from "./httpStream"; | ||
declare function batchStream(size: number): any; | ||
declare function parseJsonStream(): import("stream").Transform; | ||
declare function toLogEntryStream(options: LogflareUserOptionsI): import("stream").Transform; | ||
declare function toLogEntryStream(options: Options): import("stream").Transform; | ||
export { batchStream, parseJsonStream, toLogEntryStream, }; |
@@ -27,3 +27,3 @@ "use strict"; | ||
return through2_1.default.obj(function (chunk, enc, cb) { | ||
var entry = utils_1.toLogEntry(chunk); | ||
var entry = utils_1.handlePreparePayload(chunk, options); | ||
var maybeWithTransforms = utils_1.addLogflareTransformDirectives(entry, options); | ||
@@ -30,0 +30,0 @@ cb(null, maybeWithTransforms); |
import { LogflareUserOptionsI } from "logflare-transport-core"; | ||
import { Options } from "./httpStream"; | ||
declare type Level = "fatal" | "error" | "warn" | "info" | "debug" | "trace"; | ||
@@ -30,3 +31,3 @@ declare type SerializerFn = (value: any) => any; | ||
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, Level, LogEvent, addLogflareTransformDirectives, }; | ||
declare const handlePreparePayload: (item: Record<string, any>, options: Options) => Record<string, any>; | ||
export { handlePreparePayload, formatPinoBrowserLogEvent, Level, LogEvent, addLogflareTransformDirectives, }; |
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addLogflareTransformDirectives = exports.formatPinoBrowserLogEvent = exports.toLogEntry = void 0; | ||
exports.addLogflareTransformDirectives = exports.formatPinoBrowserLogEvent = exports.handlePreparePayload = void 0; | ||
function isObject(value) { | ||
@@ -96,3 +96,3 @@ return typeof value === "object" && value !== null; | ||
function getDocumentUrl() { | ||
if (typeof window !== 'undefined' && typeof window.document !== 'undefined') { | ||
if (typeof window !== "undefined" && typeof window.document !== "undefined") { | ||
return window.document.URL; | ||
@@ -111,3 +111,3 @@ } | ||
exports.addLogflareTransformDirectives = addLogflareTransformDirectives; | ||
function toLogEntry(item) { | ||
var extractMeta = function (item) { | ||
var status = levelToStatus(item.level); | ||
@@ -120,12 +120,29 @@ var message = item.msg || status; | ||
var type = item.type; | ||
var timestamp = item.time || new Date().getTime(); | ||
var _time = item.time, _level = item.level, _msg = item.msg, _hostname = item.hostname, _service = item.service, _pid = item.pid, _stack = item.stack, _type = item.type, cleanedItem = __rest(item, ["time", "level", "msg", "hostname", "service", "pid", "stack", "type"]); | ||
var timestamp = item.time || item.timestamp || new Date().getTime(); | ||
var _time = item.time, _level = item.level, _msg = item.msg, _hostname = item.hostname, _service = item.service, _pid = item.pid, _stack = item.stack, _type = item.type, cleanedPayload = __rest(item, ["time", "level", "msg", "hostname", "service", "pid", "stack", "type"]); | ||
var context = removeFalsy({ host: host, service: service, pid: pid, stack: stack, type: type }); | ||
return { | ||
metadata: __assign(__assign({}, cleanedItem), { context: context, level: status }), | ||
cleanedPayload: cleanedPayload, | ||
context: context, | ||
timestamp: timestamp, | ||
message: message, | ||
timestamp: timestamp, | ||
level: status, | ||
}; | ||
} | ||
exports.toLogEntry = toLogEntry; | ||
}; | ||
var defaultPreparePayload = function (_item, meta) { | ||
return { | ||
metadata: __assign(__assign({}, meta.cleanedPayload), { context: meta.context, level: meta.level }), | ||
message: meta.message, | ||
timestamp: meta.timestamp, | ||
}; | ||
}; | ||
var handlePreparePayload = function (item, options) { | ||
var meta = extractMeta(item); | ||
var callback = options && options.onPreparePayload | ||
? options.onPreparePayload | ||
: defaultPreparePayload; | ||
var result = callback(item, meta); | ||
return result; | ||
}; | ||
exports.handlePreparePayload = handlePreparePayload; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "pino-logflare", | ||
"version": "0.4.0", | ||
"version": "0.4.1-92ca7ee1", | ||
"description": "A transport for Pino that sends messages to Logflare", | ||
@@ -81,2 +81,2 @@ "homepage": "https://github.com/logflare/pino-logflare", | ||
} | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31804
453