Skip to content

Commit

Permalink
feat: re-add logger config
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Oct 9, 2020
1 parent 5ceb849 commit 17e609d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 7 additions & 5 deletions denon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

import { log } from "./deps.ts";

import { Watcher, FileEvent } from "./src/watcher.ts";
import { FileEvent, Watcher } from "./src/watcher.ts";
import { Runner } from "./src/runner.ts";
import { Daemon } from "./src/daemon.ts";

import {
grantPermissions,
initializeConfig,
printAvailableScripts,
printHelp,
initializeConfig,
grantPermissions,
upgrade,
} from "./src/cli.ts";
import { readConfig, CompleteDenonConfig, reConfig } from "./src/config.ts";
import { CompleteDenonConfig, readConfig, reConfig } from "./src/config.ts";
import { parseArgs } from "./src/args.ts";

import { VERSION, BRANCH } from "./info.ts";
import { BRANCH, VERSION } from "./info.ts";

const logger = log.create("main");

Expand Down Expand Up @@ -122,6 +122,8 @@ if (import.meta.main) {

let config = await readConfig(args.config);

await log.setup({ filter: config.logger.debug ? "DEBUG" : "INFO" });

// autocomplete(config);

config.args = args;
Expand Down
15 changes: 12 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import {
existsSync,
extname,
globToRegExp,
JSON_SCHEMA,
log,
parseYaml,
resolve,
globToRegExp,
log,
} from "../deps.ts";

import type { Args } from "./args.ts";
Expand Down Expand Up @@ -49,6 +49,11 @@ export interface CompleteDenonConfig extends RunnerConfig {
[key: string]: unknown;
watcher: WatcherConfig;
args?: Args;
logger: {
quiet: boolean;
debug: boolean;
fullscreen: boolean;
};
configPath: string;
}

Expand All @@ -63,7 +68,11 @@ export const DEFAULT_DENON_CONFIG: CompleteDenonConfig = {
skip: ["**/.git/**"],
},
watch: true,
logger: {},
logger: {
quiet: false,
debug: false,
fullscreen: false
},
configPath: "",
};

Expand Down
4 changes: 4 additions & 0 deletions src/daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class Daemon implements AsyncIterable<DenonEvent> {
private async reload(): Promise<void> {
logger.info("restarting due to changes...");

if (this.#config.logger.fullscreen) {
console.clear();
}

this.killAll();

await this.start();
Expand Down

0 comments on commit 17e609d

Please sign in to comment.