Skip to content

Commit

Permalink
Disable logging by default, rename logs() method to log()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigabyte5671 committed Jan 10, 2024
1 parent aaa475f commit 2cc50dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ All available settings:
| :----------- | :----------------- | :----------------- | :---------------------------------------------------- |
| `debug` | `true \| false` | `false` | Enable debugging output. |
| `fullscreen` | `true \| false` | `true` | Enable fullscreen mode. |
| `logs` | `path` | `{cwd}/logs` | Output log files to a specific directory. |
| `log` | `path` | `{cwd}/logs` | Output log files. |
| `map` | `map-name` | *None* | Launch directly into a particular map. |
| `position` | `number`, `number` | `0`, `0` | The position of the game window on the screen. This only takes effect in windowed mode. |
| `resolution` | `number`, `number` | *None* | The resolution of the game window. |
Expand Down
9 changes: 5 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ export class GameClient {
}

/**
* Output log files to a specific directory.
* @param logPath The directory the client should output log files to. *(defaults to `{cwd}/logs`)*.
* Output log files.
* @param path The directory the client should output log files to. *(defaults to `{cwd}/logs`)*.
*/
public logs (logPath = Defaults.logPath): GameClient {
this.#config.logPath = logPath;
public log (path = Defaults.logPath): GameClient {
this.#config.log = true;
this.#config.logPath = path;
return this;
}

Expand Down
4 changes: 3 additions & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export function createLaunchCommand (config: Config): LaunchCommand {
}

// Logs.
if (config.logPath) {
if (config.log && config.logPath) {
const time = new Date().toISOString().split(':').join('-');
const logPath = join(config.logPath, `${time}.log`).split('\\').join('/');
command.args.push(`-abslog="${logPath}"`);
} else {
command.args.push('-nowrite');
}

// Splash.
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { maps } from './maps.js';
*/
export class Config {
fullscreen = true;
log = false;
logPath = join(process.cwd(), 'logs');
map?: (typeof maps)[number];
position = {
Expand Down

0 comments on commit 2cc50dc

Please sign in to comment.