diff --git a/bin/integ b/bin/integ index 18ab7d09ee..a03ac04b0b 100755 --- a/bin/integ +++ b/bin/integ @@ -7,7 +7,7 @@ garden_bin=${garden_root}/build/src/bin/garden.js chmod +x ${garden_bin} -export GARDEN_LOGGER_TYPE=test +export GARDEN_LOGGER_TYPE=basic cd ${garden_root}/examples/hello-world diff --git a/src/logger/index.ts b/src/logger/index.ts index 2ebb6de7a3..3ae4cabd8d 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -23,17 +23,21 @@ import { LogEntryOpts, LogSymbolType, } from "./types" -import { FancyConsoleWriter, Writer } from "./writers" +import { FancyConsoleWriter, Writer, BasicConsoleWriter } from "./writers" import { ParameterError } from "../exceptions" const ROOT_DEPTH = -1 const DEFAULT_CONFIGS: {[key in LoggerType]: LoggerConfig} = { - [LoggerType.development]: { + [LoggerType.fancy]: { level: LogLevel.info, writers: [new FancyConsoleWriter()], }, - [LoggerType.test]: { - level: LogLevel.error, + [LoggerType.basic]: { + level: LogLevel.info, + writers: [new BasicConsoleWriter()], + }, + [LoggerType.quiet]: { + level: LogLevel.info, }, } @@ -50,7 +54,7 @@ export interface LogEntryConstructor { } let loggerInstance: RootLogNode -let defaultLoggerType: LoggerType = LoggerType.development +let defaultLoggerType: LoggerType = LoggerType.fancy let defaultLoggerConfig: LoggerConfig = DEFAULT_CONFIGS[defaultLoggerType] function createLogEntry(level: LogLevel, opts: LogEntryOpts, parent: LogNode) { @@ -208,8 +212,8 @@ export class LogEntry extends LogNode { return this } - public originIsNotLogger(): boolean { - return !!this.opts.originIsNotLogger + public notOriginatedFromLogger(): boolean { + return !!this.opts.notOriginatedFromLogger } public stop() { @@ -244,7 +248,7 @@ export class RootLogNode extends LogNode { } public getLogEntries(): LogEntry[] { - return getChildNodes(this).filter(entry => !entry.originIsNotLogger()) + return getChildNodes(this).filter(entry => !entry.notOriginatedFromLogger()) } public header( @@ -278,9 +282,9 @@ export class RootLogNode extends LogNode { } -export function getLogger(config: LoggerConfig = defaultLoggerConfig) { +export function getLogger(config?: LoggerConfig) { if (!loggerInstance) { - loggerInstance = new RootLogNode(config) + loggerInstance = new RootLogNode(config || defaultLoggerConfig) } return loggerInstance diff --git a/src/logger/types.ts b/src/logger/types.ts index 4cd349eafa..0c21349f32 100644 --- a/src/logger/types.ts +++ b/src/logger/types.ts @@ -23,8 +23,9 @@ export enum LogLevel { } export enum LoggerType { - development = "development", - test = "test", + basic = "basic", + fancy = "fancy", + quiet = "quiet", } // Defines entry style and format (only one available style at the moment) @@ -62,7 +63,7 @@ export interface LogEntryOpts { symbol?: LogSymbolType entryStyle?: EntryStyle append?: boolean - originIsNotLogger?: boolean + notOriginatedFromLogger?: boolean showDuration?: boolean error?: GardenError | Error } diff --git a/test/setup.ts b/test/setup.ts index 2d741ee96e..407d4df543 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -3,5 +3,5 @@ import { setDefaultLoggerType } from "../src/logger" // Global before hooks before(() => { - setDefaultLoggerType(LoggerType.test) + setDefaultLoggerType(LoggerType.quiet) })