Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #1807 #1820

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ declare namespace winston {
[optionName: string]: any;
}

interface LogMethod {
interface LogMethod {
(level: string, message: string, callback: LogCallback): Logger;
(level: string, message: string, meta: any, callback: LogCallback): Logger;
(level: string, message: string, ...meta: any[]): Logger;
Expand All @@ -74,8 +74,8 @@ declare namespace winston {
(infoObject: object): Logger;
}

interface LoggerOptions<T extends Config.AbstractConfigSetLevels = Config.AbstractConfigSetLevels> {
levels?: T;
interface LoggerOptions {
levels?: Config.AbstractConfigSetLevels;
silent?: boolean;
format?: logform.Format;
level?: string;
Expand All @@ -86,32 +86,10 @@ declare namespace winston {
exceptionHandlers?: any;
}

type DefaultLevels = {
// for cli and npm levels
error: number;
warn: number;
help: number;
data: number;
info: number;
debug: number;
prompt: number;
http: number;
verbose: number;
input: number;
silly: number;

// for syslog levels only
emerg: number;
alert: number;
crit: number;
warning: number;
notice: number;
}

type Logger<T extends Config.AbstractConfigSetLevels = DefaultLevels> = NodeJSStream.Transform & {
interface Logger extends NodeJSStream.Transform {
silent: boolean;
format: logform.Format;
levels: T;
levels: Config.AbstractConfigSetLevels;
level: string;
transports: Transport[];
exceptions: ExceptionHandler;
Expand All @@ -125,6 +103,26 @@ declare namespace winston {
clear(): Logger;
close(): Logger;

// for cli and npm levels
error: LeveledLogMethod;
warn: LeveledLogMethod;
help: LeveledLogMethod;
data: LeveledLogMethod;
info: LeveledLogMethod;
debug: LeveledLogMethod;
prompt: LeveledLogMethod;
http: LeveledLogMethod;
verbose: LeveledLogMethod;
input: LeveledLogMethod;
silly: LeveledLogMethod;

// for syslog levels only
emerg: LeveledLogMethod;
alert: LeveledLogMethod;
crit: LeveledLogMethod;
warning: LeveledLogMethod;
notice: LeveledLogMethod;

query(options?: QueryOptions, callback?: (err: Error, results: any) => void): any;
stream(options?: any): NodeJS.ReadableStream;

Expand All @@ -144,7 +142,7 @@ declare namespace winston {
isSillyEnabled(): boolean;

new(options?: LoggerOptions): Logger;
} & {[K in keyof T]: LeveledLogMethod;}
}

interface Container {
loggers: Map<string, Logger>;
Expand All @@ -164,7 +162,7 @@ declare namespace winston {
let loggers: Container;

let addColors: (target: Config.AbstractConfigSetColors) => any;
let createLogger: <T extends Config.AbstractConfigSetLevels = DefaultLevels>(options?: LoggerOptions<T>) => Logger<T>;
let createLogger: (options?: LoggerOptions) => Logger;

// Pass-through npm level methods routed to the default logger.
let error: LeveledLogMethod;
Expand Down