mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 15:04:52 +09:00
Merge pull request #748 from Cooldude2606/feature/console-log
Add config option for console logging
This commit is contained in:
4 files changed
+27
No files matched your search
@@ -218,6 +218,7 @@ export default class Instance extends lib.Link {
|
||||
enableWhitelist: this.config.get("factorio.enable_whitelist"),
|
||||
enableAuthserverBans: this.config.get("factorio.enable_authserver_bans"),
|
||||
verboseLogging: this.config.get("factorio.verbose_logging"),
|
||||
consoleLogging: this.config.get("factorio.console_logging"),
|
||||
stripPaths: this.config.get("factorio.strip_paths"),
|
||||
maxConcurrentCommands: this.config.get("factorio.max_concurrent_commands"),
|
||||
shutdownTimeoutMs: this.config.get("factorio.shutdown_timeout") * 1000,
|
||||
|
||||
@@ -438,6 +438,8 @@ export interface FactorioServerOptions {
|
||||
enableAuthserverBans?: boolean,
|
||||
/** Enable verbose logging. */
|
||||
verboseLogging?: boolean,
|
||||
/** Enable console logging. */
|
||||
consoleLogging?: boolean,
|
||||
/** Strip paths in the console. */
|
||||
stripPaths?: boolean,
|
||||
/**
|
||||
@@ -486,6 +488,8 @@ export class FactorioServer extends events.EventEmitter {
|
||||
enableAuthserverBans: boolean;
|
||||
/** Enable verbose logging */
|
||||
verboseLogging: boolean;
|
||||
/** Enable console logging */
|
||||
consoleLogging: boolean;
|
||||
_shutdownTimeoutMs = 0;
|
||||
_stopTimeoutId?: ReturnType<typeof setTimeout>;
|
||||
|
||||
@@ -541,6 +545,8 @@ export class FactorioServer extends events.EventEmitter {
|
||||
this.enableAuthserverBans = options.enableAuthserverBans || false;
|
||||
/** Enable verbose logging */
|
||||
this.verboseLogging = options.verboseLogging || false;
|
||||
/** Enable console logging */
|
||||
this.consoleLogging = options.consoleLogging || false;
|
||||
/** Maximum number of RCON commands transmitted in parallel on the RCON connection */
|
||||
this.maxConcurrentCommands = options.maxConcurrentCommands || 5;
|
||||
if (options.shutdownTimeoutMs !== undefined) {
|
||||
@@ -973,6 +979,7 @@ export class FactorioServer extends events.EventEmitter {
|
||||
...(this.enableWhitelist ? ["--use-server-whitelist"] : []),
|
||||
...(this.enableAuthserverBans ? ["--use-authserver-bans"] : []),
|
||||
...(this.verboseLogging ? ["--verbose"] : []),
|
||||
...(this.consoleLogging ? ["--console-log", this.writePath("console.log")] : []),
|
||||
],
|
||||
{
|
||||
detached: true,
|
||||
|
||||
@@ -347,6 +347,7 @@ export interface InstanceConfigFields {
|
||||
"factorio.enable_authserver_bans": boolean;
|
||||
"factorio.settings": Record<string, unknown>;
|
||||
"factorio.verbose_logging": boolean;
|
||||
"factorio.console_logging": boolean;
|
||||
"factorio.strip_paths": boolean;
|
||||
"factorio.sync_adminlist": "enabled" | "disabled" | "bidirectional";
|
||||
"factorio.sync_whitelist": "enabled" | "disabled" | "bidirectional";
|
||||
@@ -502,6 +503,12 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
type: "boolean",
|
||||
initialValue: false,
|
||||
},
|
||||
"factorio.console_logging": {
|
||||
description: "Enable console logging to a separate file, useful for 3rd party integrations",
|
||||
restartRequired: true,
|
||||
type: "boolean",
|
||||
initialValue: false,
|
||||
},
|
||||
"factorio.strip_paths": {
|
||||
description: "Strip down instance paths in the log",
|
||||
restartRequired: true,
|
||||
|
||||
@@ -451,6 +451,18 @@ describe("Integration of Clusterio", function() {
|
||||
await execCtl("instance start test --save world.zip");
|
||||
await checkInstanceStatus(44, "running");
|
||||
});
|
||||
it("allows having a separate console log", async function() {
|
||||
slowTest(this);
|
||||
await execCtl("instance stop 44");
|
||||
await execCtl("instance config set 44 factorio.console_logging true");
|
||||
await execCtl("instance start test");
|
||||
await checkInstanceStatus(44, "running");
|
||||
const checkMessage = `check${Date.now()}`;
|
||||
await sendRcon(44, checkMessage);
|
||||
const consoleLog = await fs.readFile(path.join("temp", "test", "instances", "test", "console.log"));
|
||||
assert(consoleLog.includes(checkMessage));
|
||||
await execCtl("instance config set 44 factorio.console_logging false");
|
||||
});
|
||||
it("copies the save if an autosave is the target", async function() {
|
||||
slowTest(this);
|
||||
await execCtl("instance stop 44");
|
||||
|
||||
Reference in new issue
Block a user