mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Filter out instance logs from slave console
Exclude instance related logs from the slave console as these are not significant for the running of the slave and just add noise.
This commit is contained in:
1 parent
bfe523ac45
commit
59eca88e91
2 files changed
+8
-2
No files matched your search
@@ -32,9 +32,14 @@ class ConsoleTransport extends Transport {
|
||||
super(options);
|
||||
this.errorLevels = new Set(options.errorLevels || ["fatal", "error"]);
|
||||
this.warnLevels = new Set(options.warnLevels || ["warn"]);
|
||||
this.filter = options.filter || (() => true);
|
||||
}
|
||||
|
||||
log(info, callback) {
|
||||
if (!this.filter(info)) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
if (this.errorLevels.has(info[LEVEL])) {
|
||||
console.error(info[MESSAGE]);
|
||||
@@ -44,7 +49,7 @@ class ConsoleTransport extends Transport {
|
||||
console.log(info[MESSAGE]);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
callback();
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const libPluginLoader = require("@clusterio/lib/plugin_loader");
|
||||
const libErrors = require("@clusterio/lib/errors");
|
||||
const libConfig = require("@clusterio/lib/config");
|
||||
const libSharedCommands = require("@clusterio/lib/shared_commands");
|
||||
const { ConsoleTransport, levels, logger } = require("@clusterio/lib/logging");
|
||||
const { ConsoleTransport, FilteredTransport, levels, logger } = require("@clusterio/lib/logging");
|
||||
const libLoggingUtils = require("@clusterio/lib/logging_utils");
|
||||
|
||||
const Slave = require("./src/Slave");
|
||||
@@ -126,6 +126,7 @@ async function startSlave() {
|
||||
logger.add(new ConsoleTransport({
|
||||
level: args.logLevel,
|
||||
format: new libLoggingUtils.TerminalFormat(),
|
||||
filter: info => info.instance_id === undefined,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user