@safaricom-mxl/logger
Version:
Node.js Logging Library for [MXL Console](http://mxl-console.service-availability.apps.ocpthikadev01.safaricom.net/)
71 lines (66 loc) • 2.27 kB
text/typescript
import * as _opentelemetry_api from '@opentelemetry/api';
import { Attributes } from '@opentelemetry/api';
import * as stream from 'stream';
import build from 'pino-abstract-transport';
import WinstonTransport from 'winston-transport';
type LoggerOptions = {
baseUrl?: string;
bufferSize?: number;
detectResources?: boolean;
headers?: Record<string, string>;
queueSize?: number;
resourceAttributes?: Attributes;
sendIntervalMs?: number;
service?: string;
timeout?: number;
};
declare class Logger {
private readonly logger;
private readonly processor;
constructor({ baseUrl, bufferSize, detectResources, headers, queueSize, resourceAttributes, sendIntervalMs, service, timeout, }: LoggerOptions);
shutdown(): Promise<void>;
forceFlush(): Promise<void>;
postMessage(level: string, body: string, attributes?: Attributes): void;
private parseTimestamp;
}
type MXLPinoOptions = LoggerOptions & {
apiKey?: string;
getCustomMeta?: () => Attributes;
};
declare const DEFAULT_LOG_KEYS: {
traceId: string;
spanId: string;
traceFlags: string;
};
declare const getMixinFunction: () => {
[DEFAULT_LOG_KEYS.traceId]: string;
[DEFAULT_LOG_KEYS.spanId]: string;
[DEFAULT_LOG_KEYS.traceFlags]: string;
};
declare const _default: ({ apiKey, getCustomMeta, ...options }: MXLPinoOptions) => stream.Transform & build.OnUnknown;
declare const parseWinstonLog: (log: {
message: string | Attributes;
level: string;
} & Attributes) => {
level: string;
message: string;
meta: {
[attributeKey: string]: _opentelemetry_api.AttributeValue;
};
};
type MXLWinstonOptions = LoggerOptions & {
apiKey?: string;
maxLevel?: string;
getCustomMeta?: () => Attributes;
};
declare class MXLWinston extends WinstonTransport {
private readonly logger;
private readonly getCustomMeta;
constructor({ maxLevel, getCustomMeta, apiKey, ...options }: MXLWinstonOptions);
log(info: {
message: string | Attributes;
level: string;
} & Attributes, callback: () => void): void;
close(): void;
}
export { Logger as MXLLogger, _default as MXLPino, type MXLPinoOptions, MXLWinston, type MXLWinstonOptions, getMixinFunction, parseWinstonLog };