From 6a7b75abc6668b1cd9c5a9fc1cc00bfcb04ff535 Mon Sep 17 00:00:00 2001 From: "Barth, Chris" Date: Tue, 1 Mar 2016 13:43:09 -0500 Subject: [PATCH] Update winston definitions for v2.2.x --- winston/winston-tests.ts | 4 +-- winston/winston.d.ts | 63 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/winston/winston-tests.ts b/winston/winston-tests.ts index 0147af581..46a00e4da 100644 --- a/winston/winston-tests.ts +++ b/winston/winston-tests.ts @@ -158,9 +158,9 @@ profiler.start = new Date(); let testRewriter : winston.MetadataRewriter; testRewriter = function(level: string, msg: string, meta: any) { return meta; -} +}; -winston.addRewriter(testRewriter); +logger.rewriters.push(testRewriter); /** * New Logger instances with transports tests: */ diff --git a/winston/winston.d.ts b/winston/winston.d.ts index 0dc80a57c..2cc9f10d2 100644 --- a/winston/winston.d.ts +++ b/winston/winston.d.ts @@ -7,6 +7,10 @@ /// +///****************** +/// Winston v2.2.x +///****************** + declare module "winston" { export var transports: Transports; export var Transport: TransportStatic; @@ -15,6 +19,8 @@ declare module "winston" { export var loggers: ContainerInstance; export var defaultLogger: LoggerInstance; + export var exception: Exception; + export var exitOnError: boolean; export var level: string; @@ -46,17 +52,65 @@ declare module "winston" { export function addColors(target: any): any; export function setLevels(target: any): any; export function cli(): LoggerInstance; - export function addRewriter(rewriter: MetadataRewriter): void; + export function close(): void; + + export interface ExceptionProcessInfo { + pid: number; + uid?: number; + gid?: number; + cwd: string; + execPath: string; + version: string; + argv: string; + memoryUsage: NodeJS.MemoryUsage; + } + + export interface ExceptionOsInfo { + loadavg: [number, number, number]; + uptime: number; + } + + export interface ExceptionTrace { + column: number; + file: string; + "function": string; + line: number; + method: string; + native: boolean; + } + + export interface ExceptionAllInfo { + date: Date; + process: ExceptionProcessInfo; + os: ExceptionOsInfo; + trace: Array; + stack: Array; + } + + export interface Exception { + getAllInfo(err: Error): ExceptionAllInfo; + getProcessInfo(): ExceptionProcessInfo; + getOsInfo(): ExceptionOsInfo; + getTrace(err: Error): Array; + } export interface MetadataRewriter { (level: string, msg: string, meta: any): any; } + export interface MetadataFilter { + (level: string, msg: string, meta: any): string | {msg: any; meta: any;}; + } + export interface LoggerStatic { new (options?: LoggerOptions): LoggerInstance; } export interface LoggerInstance extends NodeJS.EventEmitter { + rewriters: Array; + filters: Array; + transports: Array; + extend(target: any): LoggerInstance; log(level: string, msg: string, meta: any, callback?: (err: Error, level: string, msg: string, meta: any) => void): LoggerInstance; @@ -81,7 +135,6 @@ declare module "winston" { handleExceptions(...transports: TransportInstance[]): void; unhandleExceptions(...transports: TransportInstance[]): void; add(transport: TransportInstance, options?: TransportOptions, created?: boolean): LoggerInstance; - addRewriter(rewriter: MetadataRewriter): void; clear(): void; remove(transport: TransportInstance): LoggerInstance; startTimer(): ProfileHandler; @@ -129,6 +182,7 @@ declare module "winston" { export interface FileTransportInstance extends TransportInstance { new (options?: FileTransportOptions): FileTransportInstance; + close(): void; } export interface HttpTransportInstance extends TransportInstance { @@ -269,10 +323,7 @@ declare module "winston" { start?: number; from?: Date; until?: Date; - /** - * 'asc' or 'desc' - */ - order?: string; + order?: "asc" | "desc"; fields: any; }