style(indentation): change indentation to soft tabs

The JavaScript code was indented with spaces, so I adjusted it.
This commit is contained in:
abetomo 2020-05-22 15:58:49 +09:00
parent 5175f3f2fc
commit e27926a08e
3 changed files with 206 additions and 206 deletions

View File

@ -95,8 +95,8 @@ logger.level = 'debug';
logger.debug("Some debug messages");
configure({
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
});
```

340
types/log4js.d.ts vendored
View File

@ -3,13 +3,13 @@
type Format = string | ((req: any, res: any, formatter: ((str: string) => string)) => string);
export interface Log4js {
getLogger(category?: string): Logger;
configure(filename: string): Log4js;
configure(config: Configuration): Log4js;
addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => string): void;
connectLogger(logger: Logger, options: { format?: Format; level?: string; nolog?: any; }): any; // express.Handler;
levels: Levels;
shutdown(cb: (error: Error) => void): void | null;
getLogger(category?: string): Logger;
configure(filename: string): Log4js;
configure(config: Configuration): Log4js;
addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => string): void;
connectLogger(logger: Logger, options: { format?: Format; level?: string; nolog?: any; }): any; // express.Handler;
levels: Levels;
shutdown(cb: (error: Error) => void): void | null;
}
export function getLogger(category?: string): Logger;
@ -26,27 +26,27 @@ export const levels: Levels;
export function shutdown(cb?: (error: Error) => void): void | null;
export interface BaseLayout {
type: 'basic';
type: 'basic';
}
export interface ColoredLayout {
type: 'colored' | 'coloured';
type: 'colored' | 'coloured';
}
export interface MessagePassThroughLayout {
type: 'messagePassThrough';
type: 'messagePassThrough';
}
export interface DummyLayout {
type: 'dummy';
type: 'dummy';
}
export interface Level {
isEqualTo(other: string): boolean;
isEqualTo(otherLevel: Level): boolean;
isLessThanOrEqualTo(other: string): boolean;
isLessThanOrEqualTo(otherLevel: Level): boolean;
isGreaterThanOrEqualTo(other: string): boolean;
isEqualTo(other: string): boolean;
isEqualTo(otherLevel: Level): boolean;
isLessThanOrEqualTo(other: string): boolean;
isLessThanOrEqualTo(otherLevel: Level): boolean;
isGreaterThanOrEqualTo(other: string): boolean;
isGreaterThanOrEqualTo(otherLevel: Level): boolean;
colour: string;
level: number;
@ -54,31 +54,31 @@ export interface Level {
}
export interface LoggingEvent {
categoryName: string; // name of category
level: Level; // level of message
data: any[]; // objects to log
startTime: Date;
pid: number;
context: any;
cluster?: {
workerId: number;
worker: number;
};
categoryName: string; // name of category
level: Level; // level of message
data: any[]; // objects to log
startTime: Date;
pid: number;
context: any;
cluster?: {
workerId: number;
worker: number;
};
}
export type Token = ((logEvent: LoggingEvent) => string) | string;
export interface PatternLayout {
type: 'pattern';
// specifier for the output format, using placeholders as described below
pattern: string;
// user-defined tokens to be used in the pattern
tokens?: { [name: string]: Token };
type: 'pattern';
// specifier for the output format, using placeholders as described below
pattern: string;
// user-defined tokens to be used in the pattern
tokens?: { [name: string]: Token };
}
export interface CustomLayout {
[key: string]: any;
type: string;
[key: string]: any;
type: string;
}
export type Layout = BaseLayout | ColoredLayout | MessagePassThroughLayout | DummyLayout | PatternLayout | CustomLayout;
@ -89,11 +89,11 @@ export type Layout = BaseLayout | ColoredLayout | MessagePassThroughLayout | Dum
* @see https://log4js-node.github.io/log4js-node/categoryFilter.html
*/
export interface CategoryFilterAppender {
type: "categoryFilter";
// the category (or categories if you provide an array of values) that will be excluded from the appender.
exclude?: string | string[];
// the name of the appender to filter. see https://log4js-node.github.io/log4js-node/layouts.html
appender?: string;
type: "categoryFilter";
// the category (or categories if you provide an array of values) that will be excluded from the appender.
exclude?: string | string[];
// the name of the appender to filter. see https://log4js-node.github.io/log4js-node/layouts.html
appender?: string;
}
/**
@ -108,7 +108,7 @@ export interface NoLogFilterAppender {
// The events, which will match the regular expression, will be excluded and so not logged.
exclude: string | string[];
// the name of an appender, defined in the same configuration, that you want to filter.
appender: string;
appender: string;
}
/**
@ -117,147 +117,147 @@ export interface NoLogFilterAppender {
* @see https://log4js-node.github.io/log4js-node/console.html
*/
export interface ConsoleAppender {
type: 'console';
// defaults to colouredLayout
layout?: Layout;
type: 'console';
// defaults to colouredLayout
layout?: Layout;
}
export interface FileAppender {
type: 'file';
// the path of the file where you want your logs written.
filename: string;
// the maximum size (in bytes) for the log file. If not specified, then no log rolling will happen.
maxLogSize?: number | string;
// (default value = 5) - the number of old log files to keep during log rolling.
backups?: number;
// defaults to basic layout
layout?: Layout;
numBackups?: number;
compress?: boolean; // compress the backups
// keep the file extension when rotating logs
keepFileExt?: boolean;
encoding?: string;
mode?: number;
flags?: string;
type: 'file';
// the path of the file where you want your logs written.
filename: string;
// the maximum size (in bytes) for the log file. If not specified, then no log rolling will happen.
maxLogSize?: number | string;
// (default value = 5) - the number of old log files to keep during log rolling.
backups?: number;
// defaults to basic layout
layout?: Layout;
numBackups?: number;
compress?: boolean; // compress the backups
// keep the file extension when rotating logs
keepFileExt?: boolean;
encoding?: string;
mode?: number;
flags?: string;
}
export interface SyncfileAppender {
type: 'fileSync';
// the path of the file where you want your logs written.
filename: string;
// the maximum size (in bytes) for the log file. If not specified, then no log rolling will happen.
maxLogSize?: number | string;
// (default value = 5) - the number of old log files to keep during log rolling.
backups?: number;
// defaults to basic layout
layout?: Layout;
type: 'fileSync';
// the path of the file where you want your logs written.
filename: string;
// the maximum size (in bytes) for the log file. If not specified, then no log rolling will happen.
maxLogSize?: number | string;
// (default value = 5) - the number of old log files to keep during log rolling.
backups?: number;
// defaults to basic layout
layout?: Layout;
}
export interface DateFileAppender {
type: 'dateFile';
// the path of the file where you want your logs written.
filename: string;
// defaults to basic layout
layout?: Layout;
// defaults to .yyyy-MM-dd - the pattern to use to determine when to roll the logs.
/**
* The following strings are recognised in the pattern:
* - yyyy : the full year, use yy for just the last two digits
* - MM : the month
* - dd : the day of the month
* - hh : the hour of the day (24-hour clock)
* - mm : the minute of the hour
* - ss : seconds
* - SSS : milliseconds (although I'm not sure you'd want to roll your logs every millisecond)
* - O : timezone (capital letter o)
*/
pattern?: string;
// default “utf-8”
encoding?: string;
// default 0644
mode?: number;
// default a
flags?: string;
// compress the backup files during rolling (backup files will have .gz extension)(default false)
compress?: boolean;
// include the pattern in the name of the current log file as well as the backups.(default false)
alwaysIncludePattern?: boolean;
// keep the file extension when rotating logs
keepFileExt?: boolean;
// if this value is greater than zero, then files older than that many days will be deleted during log rolling.(default 0)
daysToKeep?: number;
type: 'dateFile';
// the path of the file where you want your logs written.
filename: string;
// defaults to basic layout
layout?: Layout;
// defaults to .yyyy-MM-dd - the pattern to use to determine when to roll the logs.
/**
* The following strings are recognised in the pattern:
* - yyyy : the full year, use yy for just the last two digits
* - MM : the month
* - dd : the day of the month
* - hh : the hour of the day (24-hour clock)
* - mm : the minute of the hour
* - ss : seconds
* - SSS : milliseconds (although I'm not sure you'd want to roll your logs every millisecond)
* - O : timezone (capital letter o)
*/
pattern?: string;
// default “utf-8”
encoding?: string;
// default 0644
mode?: number;
// default a
flags?: string;
// compress the backup files during rolling (backup files will have .gz extension)(default false)
compress?: boolean;
// include the pattern in the name of the current log file as well as the backups.(default false)
alwaysIncludePattern?: boolean;
// keep the file extension when rotating logs
keepFileExt?: boolean;
// if this value is greater than zero, then files older than that many days will be deleted during log rolling.(default 0)
daysToKeep?: number;
}
export interface LogLevelFilterAppender {
type: 'logLevelFilter';
// the name of an appender, defined in the same configuration, that you want to filter
appender: string;
// the minimum level of event to allow through the filter
level: string;
// (defaults to FATAL) - the maximum level of event to allow through the filter
maxLevel?: string;
type: 'logLevelFilter';
// the name of an appender, defined in the same configuration, that you want to filter
appender: string;
// the minimum level of event to allow through the filter
level: string;
// (defaults to FATAL) - the maximum level of event to allow through the filter
maxLevel?: string;
}
export interface MultiFileAppender {
type: 'multiFile';
// the base part of the generated log filename
base: string;
// the value to use to split files (see below).
property: string;
// the suffix for the generated log filename.
extension: string;
type: 'multiFile';
// the base part of the generated log filename
base: string;
// the value to use to split files (see below).
property: string;
// the suffix for the generated log filename.
extension: string;
}
export interface MultiprocessAppender {
type: 'multiprocess';
// controls whether the appender listens for log events sent over the network, or is responsible for serialising events and sending them to a server.
mode: 'master' | 'worker';
// (only needed if mode == master)- the name of the appender to send the log events to
appender?: string;
// (defaults to 5000) - the port to listen on, or send to
loggerPort?: number;
// (defaults to localhost) - the host/IP address to listen on, or send to
loggerHost?: string;
type: 'multiprocess';
// controls whether the appender listens for log events sent over the network, or is responsible for serialising events and sending them to a server.
mode: 'master' | 'worker';
// (only needed if mode == master)- the name of the appender to send the log events to
appender?: string;
// (defaults to 5000) - the port to listen on, or send to
loggerPort?: number;
// (defaults to localhost) - the host/IP address to listen on, or send to
loggerHost?: string;
}
export interface RecordingAppender {
type: 'recording';
type: 'recording';
}
export interface StandardErrorAppender {
type: 'stderr';
// (defaults to colouredLayout)
layout?: Layout;
type: 'stderr';
// (defaults to colouredLayout)
layout?: Layout;
}
export interface StandardOutputAppender {
type: 'stdout';
// (defaults to colouredLayout)
layout?: Layout;
type: 'stdout';
// (defaults to colouredLayout)
layout?: Layout;
}
export interface CustomAppender {
type: string | AppenderModule;
[key: string]: any;
type: string | AppenderModule;
[key: string]: any;
}
export interface AppenderModule {
configure: Function
configure: Function
}
export type Appender = CategoryFilterAppender
| ConsoleAppender
| FileAppender
| SyncfileAppender
| DateFileAppender
| ConsoleAppender
| FileAppender
| SyncfileAppender
| DateFileAppender
| LogLevelFilterAppender
| NoLogFilterAppender
| MultiFileAppender
| MultiprocessAppender
| RecordingAppender
| StandardErrorAppender
| StandardOutputAppender
| CustomAppender;
| MultiFileAppender
| MultiprocessAppender
| RecordingAppender
| StandardErrorAppender
| StandardOutputAppender
| CustomAppender;
export interface Levels {
ALL: Level;
@ -275,51 +275,51 @@ export interface Levels {
}
export interface Configuration {
appenders: { [name: string]: Appender; };
categories: { [name: string]: { appenders: string[]; level: string; enableCallStack?: boolean; } };
pm2?: boolean;
pm2InstanceVar?: string;
levels?: Levels;
disableClustering?: boolean;
appenders: { [name: string]: Appender; };
categories: { [name: string]: { appenders: string[]; level: string; enableCallStack?: boolean; } };
pm2?: boolean;
pm2InstanceVar?: string;
levels?: Levels;
disableClustering?: boolean;
}
export class Logger {
new(dispatch: Function, name: string): Logger;
new(dispatch: Function, name: string): Logger;
level: string;
level: string;
log(...args: any[]): void;
log(...args: any[]): void;
isLevelEnabled(level?: string): boolean;
isLevelEnabled(level?: string): boolean;
isTraceEnabled(): boolean;
isDebugEnabled(): boolean;
isInfoEnabled(): boolean;
isWarnEnabled(): boolean;
isErrorEnabled(): boolean;
isFatalEnabled(): boolean;
isTraceEnabled(): boolean;
isDebugEnabled(): boolean;
isInfoEnabled(): boolean;
isWarnEnabled(): boolean;
isErrorEnabled(): boolean;
isFatalEnabled(): boolean;
_log(level: string, data: any): void;
_log(level: string, data: any): void;
addContext(key: string, value: any): void;
addContext(key: string, value: any): void;
removeContext(key: string): void;
removeContext(key: string): void;
clearContext(): void;
clearContext(): void;
setParseCallStackFunction(parseFunction: Function): void;
setParseCallStackFunction(parseFunction: Function): void;
trace(message: any, ...args: any[]): void;
trace(message: any, ...args: any[]): void;
debug(message: any, ...args: any[]): void;
debug(message: any, ...args: any[]): void;
info(message: any, ...args: any[]): void;
info(message: any, ...args: any[]): void;
warn(message: any, ...args: any[]): void;
warn(message: any, ...args: any[]): void;
error(message: any, ...args: any[]): void;
error(message: any, ...args: any[]): void;
fatal(message: any, ...args: any[]): void;
fatal(message: any, ...args: any[]): void;
mark(message: any, ...args: any[]): void;
mark(message: any, ...args: any[]): void;
}

View File

@ -17,41 +17,41 @@ logger3.error('Cheese is too ripe!');
logger3.fatal('Cheese was breeding ground for listeria.');
log4js.configure({
appenders: { cheese: { type: 'console', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
appenders: { cheese: { type: 'console', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
});
log4js.configure({
appenders: {
out: { type: 'file', filename: 'pm2logs.log' }
},
categories: {
default: { appenders: ['out'], level: 'info' }
},
pm2: true,
pm2InstanceVar: 'INSTANCE_ID'
appenders: {
out: { type: 'file', filename: 'pm2logs.log' }
},
categories: {
default: { appenders: ['out'], level: 'info' }
},
pm2: true,
pm2InstanceVar: 'INSTANCE_ID'
});
log4js.addLayout('json', config => function (logEvent) {
return JSON.stringify(logEvent) + config.separator;
return JSON.stringify(logEvent) + config.separator;
});
log4js.configure({
appenders: {
out: { type: 'stdout', layout: { type: 'json', separator: ',' } }
},
categories: {
default: { appenders: ['out'], level: 'info' }
}
appenders: {
out: { type: 'stdout', layout: { type: 'json', separator: ',' } }
},
categories: {
default: { appenders: ['out'], level: 'info' }
}
});
log4js.configure({
appenders: {
file: { type: 'dateFile', filename: 'thing.log', pattern: '.mm' }
},
categories: {
default: { appenders: ['file'], level: 'debug' }
}
appenders: {
file: { type: 'dateFile', filename: 'thing.log', pattern: '.mm' }
},
categories: {
default: { appenders: ['file'], level: 'debug' }
}
});
const logger4 = log4js.getLogger('thing');
@ -64,15 +64,15 @@ logger5.warn('that outputs json');
log4js.shutdown();
log4js.configure({
appenders: {
cheeseLogs: { type: 'file', filename: 'cheese.log' },
console: { type: 'console' }
},
categories: {
cheese: { appenders: ['cheeseLogs'], level: 'error' },
another: { appenders: ['console'], level: 'trace' },
default: { appenders: ['console', 'cheeseLogs'], level: 'trace' }
}
appenders: {
cheeseLogs: { type: 'file', filename: 'cheese.log' },
console: { type: 'console' }
},
categories: {
cheese: { appenders: ['cheeseLogs'], level: 'error' },
another: { appenders: ['console'], level: 'trace' },
default: { appenders: ['console', 'cheeseLogs'], level: 'trace' }
}
});
const logger6 = log4js.getLogger('cheese');
@ -109,8 +109,8 @@ logger2.level = 'debug';
logger2.debug("Some debug messages");
configure({
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
});
log4js.configure('./filename').getLogger();