Add overload

This commit is contained in:
syuilo 2016-12-29 21:14:47 +09:00
parent d511e11293
commit ebe3225e0c

View File

@ -10,9 +10,12 @@ function toLevelColor(level: LogLevel): chalk.ChalkStyle {
}
}
export function log(message: string): void;
export function log(level: LogLevel, message: string): void;
export function log(level: LogLevel, message: string, domain: string): void;
export function log(level: LogLevel, message: string, domain?: string): void {
export function log(x: string | LogLevel, message?: string, domain?: string): void {
const level = typeof message == 'undefined' ? 'Info' : x as LogLevel;
message = typeof message == 'undefined' ? x : message;
if (typeof domain == 'string') {
log(level, `[${domain}] ${message}`);
} else {