Skip to content

Commit

Permalink
Add scriptevent variants for logging and fix documentation for script…
Browse files Browse the repository at this point in the history
…events
  • Loading branch information
stirante committed Feb 8, 2024
1 parent c7d45c9 commit f4d6dd4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ log.info("Hello, Minecraft World!");

It also includes 2 commands to control the logging system:
```
scriptevent logger:level <level either as string or as a number>
scriptevent logger:filter <comma separated tags>
scriptevent logging:level <level either as string or as a number>
# or
scriptevent log:level <level either as string or as a number>
scriptevent logging:filter <comma separated tags>
# or
scriptevent log:filter <comma separated tags>
```

### ChatColor and ColorJSON classes
Expand Down
9 changes: 7 additions & 2 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ logger.info("Hello, world!", { foo: "bar"});
The logging system includes 2 commands to control the logging system:

```
scriptevent logger:level <level either as string or as a number>
scriptevent logger:filter <comma separated tags>
scriptevent logging:level <level either as string or as a number>
# or
scriptevent log:level <level either as string or as a number>
scriptevent logging:filter <comma separated tags>
# or
scriptevent log:filter <comma separated tags>
```

## Build Options
Expand Down
4 changes: 2 additions & 2 deletions src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class Logger {
if (Logger.initialized) return;
Logger.initialized = true;
system.afterEvents.scriptEventReceive.subscribe((ev) => {
if (ev.id === 'logging:level') {
if (ev.id === 'logging:level' || ev.id === 'log:level') {
if (!ev.message) {
loggingSettings.level = LogLevel.Info;
world.sendMessage(`${ChatColor.AQUA}Logging level set to ${ChatColor.BOLD}${loggingSettings.level}`);
Expand All @@ -137,7 +137,7 @@ export class Logger {
world.sendMessage(`${ChatColor.DARK_RED}Invalid logging level: ${ev.message}`);
}
}
} else if (ev.id === 'logging:filter') {
} else if (ev.id === 'logging:filter' || ev.id === 'log:filter') {
if (!ev.message) {
loggingSettings.filter = ['*'];
} else {
Expand Down

0 comments on commit f4d6dd4

Please sign in to comment.