Skip to content

Commit

Permalink
fix(typings): correctly type the levels property
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Jul 4, 2018
1 parent 70bcfaa commit 18ad653
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 13 additions & 6 deletions types/log4js.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface Log4js {
configure(config: Configuration): Log4js;
addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => string): void;
connectLogger(logger: Logger, options: { format?: string; level?: string; nolog?: any; }): any; // express.Handler;
levels(): Levels;
levels: Levels;
shutdown(cb?: (error: Error) => void): void | null;
}

Expand All @@ -19,7 +19,7 @@ export function addLayout(name: string, config: (a: any) => (logEvent: LoggingEv

export function connectLogger(logger: Logger, options: { format?: string; level?: string; nolog?: any; }): any; // express.Handler;

export function levels(): Levels;
export const levels: Levels;

export function shutdown(cb?: (error: Error) => void): void | null;

Expand Down Expand Up @@ -409,10 +409,17 @@ export type Appender = CategoryFilterAppender
| CustomAppender;

export interface Levels {
[index: string]: {
value: number;
colour: string;
};
ALL: Level;
MARK: Level;
TRACE: Level;
DEBUG: Level;
INFO: Level;
WARN: Level;
ERROR: Level;
FATAL: Level;
OFF: Level;
levels: Level[];
getLevel(level: string): Level;
}

export interface Configuration {
Expand Down
3 changes: 3 additions & 0 deletions types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,6 @@ log4js.configure('./filename').getLogger();
const logger7 = log4js.getLogger();
logger7.level = 'debug';
logger7.debug("Some debug messages");

const levels: log4js.Levels = log4js.levels;
const level: log4js.Level = levels.getLevel('info');

0 comments on commit 18ad653

Please sign in to comment.