mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
introduced useUTC parameter for logs (#344)
This commit is contained in:
@@ -233,6 +233,7 @@ logging:
|
|||||||
maxRetainedFiles: 10
|
maxRetainedFiles: 10
|
||||||
maxFileSizeMB: 15
|
maxFileSizeMB: 15
|
||||||
compressOnRotation: false
|
compressOnRotation: false
|
||||||
|
useUTC: true
|
||||||
|
|
||||||
checkForUpdatesAtBoot: true
|
checkForUpdatesAtBoot: true
|
||||||
generatePrefixListEveryDays: 2
|
generatePrefixListEveryDays: 2
|
||||||
|
@@ -14,6 +14,7 @@ The following are common parameters which it is possible to specify in the confi
|
|||||||
|logging.compressOnRotation| Indicates if when a file gets rotates it has to be compressed or not. | A boolean | true | Yes |
|
|logging.compressOnRotation| Indicates if when a file gets rotates it has to be compressed or not. | A boolean | true | Yes |
|
||||||
|logging.maxFileSizeMB| Indicates the maximum file size in MB allowed before to be rotated. This allows to rotate files when logRotatePattern still the same but the file is too big | An integer | 15 | Yes |
|
|logging.maxFileSizeMB| Indicates the maximum file size in MB allowed before to be rotated. This allows to rotate files when logRotatePattern still the same but the file is too big | An integer | 15 | Yes |
|
||||||
|logging.maxRetainedFiles| Indicates the maximum amount of log files retained. When this threshold is passed, files are deleted. | An integer | 10 | Yes |
|
|logging.maxRetainedFiles| Indicates the maximum amount of log files retained. When this threshold is passed, files are deleted. | An integer | 10 | Yes |
|
||||||
|
|logging.useUTC| If set to true, logs will be reported in UTC time. Is set to false or missing, the timezone of the machine will be used. This parameter affects only the timestamp reported at the beginning of each log entry, it doesn't affect the time reported in the data/alerts which is always in UTC. | A boolean | true | No |
|
||||||
|checkForUpdatesAtBoot| Indicates if at each booth the application should check for updates. If an update is available, a notification will be sent to the default group. If you restart the process often (e.g. debugging, experimenting etc.) set this to false to avoid notifications. Anyway, BGPalerter checks for updates every 10 days.| A boolean | true | Yes |
|
|checkForUpdatesAtBoot| Indicates if at each booth the application should check for updates. If an update is available, a notification will be sent to the default group. If you restart the process often (e.g. debugging, experimenting etc.) set this to false to avoid notifications. Anyway, BGPalerter checks for updates every 10 days.| A boolean | true | Yes |
|
||||||
|processMonitors| A list of modules allowing various ways to check for the status of BGPalerter (e.g. API, heartbeat). See [here](process-monitors.md) for more information. | | | No |
|
|processMonitors| A list of modules allowing various ways to check for the status of BGPalerter (e.g. API, heartbeat). See [here](process-monitors.md) for more information. | | | No |
|
||||||
|httpProxy| Defines the HTTP/HTTPS proxy server to be used by BGPalerter and its submodules (reporters/connectors/monitors). See [here](http-proxy.md) for more information. | A string | http://usr:psw@ prxy.org:8080 | No |
|
|httpProxy| Defines the HTTP/HTTPS proxy server to be used by BGPalerter and its submodules (reporters/connectors/monitors). See [here](http-proxy.md) for more information. | A string | http://usr:psw@ prxy.org:8080 | No |
|
||||||
|
@@ -213,6 +213,7 @@ const errorTransport = new FileLogger({
|
|||||||
maxFileSizeMB: config.logging.maxFileSizeMB,
|
maxFileSizeMB: config.logging.maxFileSizeMB,
|
||||||
compressOnRotation: config.logging.compressOnRotation,
|
compressOnRotation: config.logging.compressOnRotation,
|
||||||
label: config.environment,
|
label: config.environment,
|
||||||
|
useUTC: !!config.logging.useUTC,
|
||||||
format: ({data, timestamp}) => `${timestamp} ${data.level}: ${data.message}`
|
format: ({data, timestamp}) => `${timestamp} ${data.level}: ${data.message}`
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -225,6 +226,7 @@ const verboseTransport = new FileLogger({
|
|||||||
maxFileSizeMB: config.logging.maxFileSizeMB,
|
maxFileSizeMB: config.logging.maxFileSizeMB,
|
||||||
compressOnRotation: config.logging.compressOnRotation,
|
compressOnRotation: config.logging.compressOnRotation,
|
||||||
label: config.environment,
|
label: config.environment,
|
||||||
|
useUTC: !!config.logging.useUTC,
|
||||||
format: ({data, timestamp}) => `${timestamp} ${data.level}: ${data.message}`
|
format: ({data, timestamp}) => `${timestamp} ${data.level}: ${data.message}`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ export default class FileLogger {
|
|||||||
this.format = params.format || this.defaultFormat;
|
this.format = params.format || this.defaultFormat;
|
||||||
this.logRotatePattern = params.logRotatePattern || "YYYY-MM-DD";
|
this.logRotatePattern = params.logRotatePattern || "YYYY-MM-DD";
|
||||||
this.filename = params.filename;
|
this.filename = params.filename;
|
||||||
|
this.useUTC = params.useUTC;
|
||||||
this.directory = params.directory;
|
this.directory = params.directory;
|
||||||
this.levels = params.levels || ['error', 'info', 'verbose'];
|
this.levels = params.levels || ['error', 'info', 'verbose'];
|
||||||
|
|
||||||
@@ -41,17 +42,25 @@ export default class FileLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${this.directory}/${this.filename.replace("%DATE%", moment().format(this.logRotatePattern))}${suffix}`;
|
return `${this.directory}/${this.filename.replace("%DATE%", this.getCurrentDate().format(this.logRotatePattern))}${suffix}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = (json) => {
|
defaultFormat = (json) => {
|
||||||
return JSON.stringify(json);
|
return JSON.stringify(json);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getCurrentDate = () => {
|
||||||
|
if (this.useUTC) {
|
||||||
|
return moment.utc();
|
||||||
|
} else {
|
||||||
|
return moment();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
log = (data) => {
|
log = (data) => {
|
||||||
|
|
||||||
const item = this.format({
|
const item = this.format({
|
||||||
timestamp: moment().format('YYYY-MM-DDTHH:mm:ssZ'),
|
timestamp: this.getCurrentDate().format('YYYY-MM-DDTHH:mm:ssZ'),
|
||||||
data
|
data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user