@tsed/logger
Advanced tools
Comparing version 5.2.1 to 5.3.0
@@ -58,5 +58,21 @@ /** | ||
* ``` | ||
* > This will result in one current log file (all-the-logs.log). When that reaches 10Mb in size, it will be renamed and compressed to all-the-logs.log.1.gz and a new file opened called all-the-logs.log. When all-the-logs.log reaches 10Mb again, then all-the-logs.log.1.gz will be renamed to all-the-logs.log.2.gz, and so on. | ||
* | ||
* @private | ||
* ::: | ||
* This will result in one current log file (all-the-logs.log). When that reaches 10Mb in size, it will be renamed and compressed to all-the-logs.log.1.gz and a new file opened called all-the-logs.log. When all-the-logs.log reaches 10Mb again, then all-the-logs.log.1.gz will be renamed to all-the-logs.log.2.gz, and so on. | ||
* ::: | ||
* | ||
* ## Example with date rolling | ||
* | ||
* ```typescript | ||
* import { Logger } from 'ts-log-debug'; | ||
* export const logger = new Logger('Log Example'); | ||
* | ||
* logger.appenders | ||
* .set('file', { | ||
* type: 'file', | ||
* filename: `${__dirname}/../logs/myfile.log`, | ||
* pattern: '.yyyy-MM-dd' | ||
* }); | ||
* ``` | ||
* | ||
*/ | ||
@@ -63,0 +79,0 @@ export declare class FileAppender extends BaseAppender { |
@@ -65,5 +65,21 @@ "use strict"; | ||
* ``` | ||
* > This will result in one current log file (all-the-logs.log). When that reaches 10Mb in size, it will be renamed and compressed to all-the-logs.log.1.gz and a new file opened called all-the-logs.log. When all-the-logs.log reaches 10Mb again, then all-the-logs.log.1.gz will be renamed to all-the-logs.log.2.gz, and so on. | ||
* | ||
* @private | ||
* ::: | ||
* This will result in one current log file (all-the-logs.log). When that reaches 10Mb in size, it will be renamed and compressed to all-the-logs.log.1.gz and a new file opened called all-the-logs.log. When all-the-logs.log reaches 10Mb again, then all-the-logs.log.1.gz will be renamed to all-the-logs.log.2.gz, and so on. | ||
* ::: | ||
* | ||
* ## Example with date rolling | ||
* | ||
* ```typescript | ||
* import { Logger } from 'ts-log-debug'; | ||
* export const logger = new Logger('Log Example'); | ||
* | ||
* logger.appenders | ||
* .set('file', { | ||
* type: 'file', | ||
* filename: `${__dirname}/../logs/myfile.log`, | ||
* pattern: '.yyyy-MM-dd' | ||
* }); | ||
* ``` | ||
* | ||
*/ | ||
@@ -98,3 +114,3 @@ let FileAppender = class FileAppender extends BaseAppender_1.BaseAppender { | ||
build() { | ||
let { filename: file, maxLogSize: logSize, backups: numBackups } = this.config; | ||
let { filename: file, maxLogSize: logSize, backups: numBackups, pattern } = this.config; | ||
file = Path.normalize(file); | ||
@@ -104,3 +120,3 @@ numBackups = numBackups === undefined ? 5 : numBackups; | ||
numBackups = numBackups === 0 ? 1 : numBackups; | ||
this.writer = this.openTheStream(file, logSize, numBackups, this.config); | ||
this.writer = this.openTheStream(file, logSize, numBackups, pattern, this.config); | ||
// On SIGHUP, close and reopen all files. This allows this appender to work with | ||
@@ -120,4 +136,10 @@ // logrotate. Note that if you are using logrotate, you should not set | ||
*/ | ||
openTheStream(file, fileSize, numFiles, options) { | ||
const stream = new streams.RollingFileStream(file, fileSize, numFiles, options); | ||
openTheStream(file, fileSize, numFiles, pattern, options) { | ||
let stream = null; | ||
if (pattern) { | ||
stream = new streams.DateRollingFileStream(file, pattern, options); | ||
} | ||
else { | ||
stream = new streams.RollingFileStream(file, fileSize, numFiles, options); | ||
} | ||
stream.on("error", (err) => { | ||
@@ -124,0 +146,0 @@ console.error("FileAppender - Writing to file %s, error happened ", file, err); |
@@ -11,2 +11,3 @@ /** | ||
maxLogSize?: number; | ||
pattern?: string; | ||
backups?: number; | ||
@@ -13,0 +14,0 @@ levels?: string[]; |
{ | ||
"name": "@tsed/logger", | ||
"version": "5.2.1", | ||
"version": "5.3.0", | ||
"description": "A multi channel logger written in TypeScript.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
191511
3061