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

feat(typing): improving @types for AppenderModule #1079

Merged
merged 3 commits into from Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 30 additions & 1 deletion types/log4js.d.ts
Expand Up @@ -242,9 +242,38 @@ export interface CustomAppender {
}

export interface AppenderModule {
configure: Function
configure: (config: Config, layouts: LayoutsParam) => AppenderGenerator;
}

export type AppenderGenerator = (
layout: LayoutFunction,
timezoneOffset?: string
) => AppenderFunction;

export type AppenderFunction = (loggingEvent: LoggingEvent) => void;

// TODO: Actually add types here...
// It's supposed to be the full config element
export type Config = any

export interface LayoutsParam {
basicLayout: LayoutFunction;
messagePassThroughLayout: LayoutFunction;
patternLayout: LayoutFunction;
colouredLayout: LayoutFunction;
coloredLayout: LayoutFunction;
dummyLayout: LayoutFunction;
addLayout: (name: string, serializerGenerator: LayoutFunction) => void;
layout: (name: string, config: PatternToken) => LayoutFunction;
}

export interface PatternToken {
pattern: string; // TODO type this to enforce good pattern...
tokens: { [tokenName: string]: () => any };
}

export type LayoutFunction = (loggingEvent: LoggingEvent) => string;

export type Appender = CategoryFilterAppender
| ConsoleAppender
| FileAppender
Expand Down