Skip to content

Commit

Permalink
Merge pull request #1240 from log4js-node/update-docs
Browse files Browse the repository at this point in the history
chore(docs): updated comments in typescript def
  • Loading branch information
lamweili committed May 11, 2022
2 parents 3b56fae + 126e286 commit 362a397
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/connect-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ app.use(log4js.connectLogger(logger, {

When you request of POST, you want to log the request body parameter like JSON.
The log format function is very useful.
Please use log format function instead tokens property for use express's request or response.
Please use log format function instead "tokens" property for use express's request or response.


```javascript
Expand Down
2 changes: 1 addition & 1 deletion docs/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The file appender writes log events to a file. It supports an optional maximum f
* `type` - `"file"`
* `filename` - `string` - the path of the file where you want your logs written.
* `maxLogSize` - `integer` (optional, defaults to MAX_SAFE_INTEGER) - the maximum size (in bytes) for the log file.
* `backups` - `integer` (optional, defaults to 5) - the number of old log files to keep during log rolling.
* `backups` - `integer` (optional, defaults to 5) - the number of old log files to keep during log rolling (excluding the hot file).
* `layout` - (optional, defaults to basic layout) - see [layouts](layouts.md)

Any other configuration parameters will be passed to the underlying [streamroller](https://github.com/nomiddlename/streamroller) implementation (see also node.js core file streams):
Expand Down
2 changes: 1 addition & 1 deletion docs/fileSync.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The sync file appender writes log events to a file, the only difference to the n
* `type` - `"fileSync"`
* `filename` - `string` - the path of the file where you want your logs written.
* `maxLogSize` - `integer` (optional) - the maximum size (in bytes) for the log file. If not specified or 0, then no log rolling will happen.
* `backups` - `integer` (optional, defaults to 5) - the number of old log files to keep during log rolling.
* `backups` - `integer` (optional, defaults to 5) - the number of old log files to keep during log rolling (excluding the hot file).
* `layout` - (optional, defaults to basic layout) - see [layouts](layouts.md)

Any other configuration parameters will be passed to the underlying node.js core stream implementation:
Expand Down
73 changes: 40 additions & 33 deletions types/log4js.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const levels: Levels;

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

export interface BaseLayout {
export interface BasicLayout {
type: 'basic';
}

Expand Down Expand Up @@ -88,7 +88,7 @@ export interface CustomLayout {
type: string;
}

export type Layout = BaseLayout | ColoredLayout | MessagePassThroughLayout | DummyLayout | PatternLayout | CustomLayout;
export type Layout = BasicLayout | ColoredLayout | MessagePassThroughLayout | DummyLayout | PatternLayout | CustomLayout;

/**
* Category Filter
Expand Down Expand Up @@ -125,50 +125,55 @@ export interface NoLogFilterAppender {
*/
export interface ConsoleAppender {
type: 'console';
// defaults to colouredLayout
// (defaults to ColoredLayout)
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.
// (defaults to MAX_SAFE_INTEGER) the maximum size (in bytes) for the log file.
maxLogSize?: number | string;
// (default value = 5) - the number of old log files to keep during log rolling.
// (defaults to 5) the number of old log files to keep (excluding the hot file).
backups?: number;
// defaults to basic layout
// (defaults to BasicLayout)
layout?: Layout;
compress?: boolean; // compress the backups
// keep the file extension when rotating logs
keepFileExt?: boolean;
// (defaults to utf-8)
encoding?: string;
// (defaults to 0o600)
mode?: number;
// (defaults to a)
flags?: string;
// (defaults to false) compress the backup files using gzip (backup files will have .gz extension)
compress?: boolean;
// (defaults to false) preserve the file extension when rotating log files (`file.log` becomes `file.1.log` instead of `file.log.1`).
keepFileExt?: boolean;
}

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.
// (defaults to undefined) the maximum size (in bytes) for the log file. If not specified or 0, then no log rolling will happen.
maxLogSize?: number | string;
// (default value = 5) - the number of old log files to keep during log rolling.
// (defaults to 5) the number of old log files to keep (excluding the hot file).
backups?: number;
// defaults to basic layout
// (defaults to BasicLayout)
layout?: Layout;
// (defaults to utf-8)
encoding?: string;
// (defaults to 0o600)
mode?: number;
// (defaults to a)
flags?: string;
}

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.
// (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
Expand All @@ -181,19 +186,21 @@ export interface DateFileAppender {
* - O : timezone (capital letter o)
*/
pattern?: string;
// default “utf-8”
// (defaults to BasicLayout)
layout?: Layout;
// (defaults to utf-8)
encoding?: string;
// default 0600
// (defaults to 0o600)
mode?: number;
// default ‘a’
// (defaults to a)
flags?: string;
// compress the backup files during rolling (backup files will have .gz extension)(default false)
// (defaults to false) compress the backup files using gzip (backup files will have .gz extension)
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
// (defaults to false) preserve the file extension when rotating log files (`file.log` becomes `file.2017-05-30.log` instead of `file.log.2017-05-30`).
keepFileExt?: boolean;
// if this value is greater than zero, then files older than that many days will be deleted during log rolling.(default 0)
// (defaults to false) include the pattern in the name of the current log file.
alwaysIncludePattern?: boolean;
// (defaults to 1) the number of old files that matches the pattern to keep (excluding the hot file).
numBackups?: number;
}

Expand All @@ -203,7 +210,7 @@ export interface LogLevelFilterAppender {
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
// (defaults to FATAL) the maximum level of event to allow through the filter
maxLevel?: string;
}

Expand All @@ -221,11 +228,11 @@ 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
// (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
// (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
// (defaults to localhost) the host/IP address to listen on, or send to
loggerHost?: string;
}

Expand All @@ -235,13 +242,13 @@ export interface RecordingAppender {

export interface StandardErrorAppender {
type: 'stderr';
// (defaults to colouredLayout)
// (defaults to ColoredLayout)
layout?: Layout;
}

export interface StandardOutputAppender {
type: 'stdout';
// (defaults to colouredLayout)
// (defaults to ColoredLayout)
layout?: Layout;
}

Expand All @@ -252,13 +259,13 @@ export interface StandardOutputAppender {
*/
export interface TCPAppender {
type: 'tcp';
// defaults to 5000
// (defaults to 5000)
port?: number
// defaults to localhost
// (defaults to localhost)
host?: string
// default to __LOG4JS__
// (defaults to __LOG4JS__)
endMsg?: string
// defaults to a serialized log event
// (defaults to a serialized log event)
layout?: Layout;
}

Expand Down

0 comments on commit 362a397

Please sign in to comment.