From f5e94139292626c730b43f7289fde4475eb2d92e Mon Sep 17 00:00:00 2001 From: Andrew Stacy Date: Thu, 2 Dec 2021 12:28:32 -0500 Subject: [PATCH] feat: logs now always render and printed boolean now returned when terminated (#93) Logs will always render and store their render. To know if a log was printed to the console terminated logs now expose the "printed" boolean that indicates if it was printed. Log listeners also now receive the printed boolean. Rather than checking for render equal to null, listeners should now check the printed boolean. Co-authored-by: Andrew Stacy --- src/_contracts/Log.ts | 2 + src/_contracts/Shed.ts | 3 +- src/index.ts | 4 +- src/log/BaseLog.ts | 69 +++++---- src/shed/Shed.ts | 8 +- test/adze.ts | 206 +++++++++++++------------- test/browser/customize.ts | 2 +- test/browser/defaults-emoji.ts | 2 +- test/browser/defaults.ts | 2 +- test/browser/modifiers/conditional.ts | 2 +- test/browser/modifiers/counting.ts | 2 +- test/browser/modifiers/grouping.ts | 2 +- test/browser/modifiers/identifying.ts | 2 +- test/browser/modifiers/mdc.ts | 2 +- test/browser/modifiers/timing.ts | 2 +- test/bundle.ts | 2 +- test/filters.ts | 3 +- test/formatting.ts | 2 +- test/grouping.ts | 2 +- test/identifying.ts | 2 +- test/mdc.ts | 2 +- test/meta.ts | 2 +- test/node/customize.ts | 2 +- test/node/defaults-emoji.ts | 2 +- test/node/defaults.ts | 2 +- test/node/modifiers/conditional.ts | 2 +- test/node/modifiers/counting.ts | 2 +- test/node/modifiers/grouping.ts | 2 +- test/node/modifiers/identifying.ts | 2 +- test/node/modifiers/mdc.ts | 2 +- test/node/modifiers/timing.ts | 2 +- test/seal.ts | 2 +- test/shed.ts | 7 +- 33 files changed, 186 insertions(+), 166 deletions(-) diff --git a/src/_contracts/Log.ts b/src/_contracts/Log.ts index 214aee90..b4d7a342 100644 --- a/src/_contracts/Log.ts +++ b/src/_contracts/Log.ts @@ -74,6 +74,7 @@ export interface LogData { dumpContext: boolean; expression?: boolean; isSilent: boolean; + printed: boolean; label: LabelData; level: number | null; meta: MetaData; @@ -104,4 +105,5 @@ export interface FinalLogData extends LogData { export interface TerminatedLog { log: I; render: LogRender | null; + printed: boolean; } diff --git a/src/_contracts/Shed.ts b/src/_contracts/Shed.ts index c0897bb8..8e3884bd 100644 --- a/src/_contracts/Shed.ts +++ b/src/_contracts/Shed.ts @@ -12,7 +12,8 @@ export type ListenerBucket = Map; export type ListenerCallback = ( LogData: LogData | FinalLogData, - render: LogRender | null + render: LogRender | null, + printed: boolean ) => void; export interface ShedConfig { diff --git a/src/index.ts b/src/index.ts index 34fa4ac3..2c589721 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,6 @@ -export { adze } from './adze'; +import { adze } from './adze'; +export { adze }; +export default adze; export { Label } from './label'; export { defaults } from './_defaults'; export { diff --git a/src/log/BaseLog.ts b/src/log/BaseLog.ts index e122620b..a0f43405 100644 --- a/src/log/BaseLog.ts +++ b/src/log/BaseLog.ts @@ -131,6 +131,11 @@ export class BaseLog { */ private isSilent = false; + /** + * Flag which indicates if the log is allowed to print to the console. + */ + private printed = false; + /** * Flag which tells the log instance to add the * MDC context to the log render arguments. @@ -765,41 +770,41 @@ export class BaseLog { // Apply modifiers in the proper order. this.runModifierQueue(); - // Check the test modifiers. - if (this.evalPasses()) { - // Save values to this log instance for later recall - this.args = args; - this._level = def.level; - this.definition = def; - this._timestamp = timestamp(); - this.stacktrace = this.cfg.captureStacktrace ? stacktrace() : null; - - // Set this log data to a variable for type checking - const log_data = this.data; - - if (isFinalLogData(log_data)) { - // Render the log if it's allowed to print - this._render = allowed(log_data) - ? new Printer(log_data)[this.printer]() - : null; - - // Attempt to print the render to the console / terminal - toConsole(this._render); + // Save values to this log instance for later recall + this.args = args; + this._level = def.level; + this.definition = def; + this._timestamp = timestamp(); + this.stacktrace = this.cfg.captureStacktrace ? stacktrace() : null; + + // Set this log data to a variable for type checking + const log_data = this.data; - // Cache the log - this.store(); + if (isFinalLogData(log_data)) { + // Render the log + this._render = new Printer(log_data)[this.printer](); - // Fire the log listeners - this.fireListeners(log_data, this._render); + // Evaluates if this log can print + this.printed = allowed(log_data) && this.evalPasses(); - // Return the terminated log object with a render - return { log: this, render: this._render }; + // Attempt to print the render to the console / terminal + if (this.printed) { + toConsole(this._render); } + + // Cache the log + this.store(); + + // Fire the log listeners + this.fireListeners(log_data, this._render, this.printed); + + // Return the terminated log object with a render + return { log: this, render: this._render, printed: this.printed }; } } // Return the terminated log object unrendered - return { log: this, render: null }; + return { log: this, render: null, printed: false }; } /** @@ -838,10 +843,14 @@ export class BaseLog { /** * Fires listeners for this log instance if a Shed exists. */ - private fireListeners(data: FinalLogData, render: LogRender | null): void { + private fireListeners( + data: FinalLogData, + render: LogRender | null, + printed: boolean + ): void { const shed = this.env.global.$shed; if (shedExists(shed)) { - shed.fireListeners(data, render); + shed.fireListeners(data, render, printed); } } @@ -871,6 +880,7 @@ export class BaseLog { expression: this.expression, dumpContext: this.dumpContext, isSilent: this.isSilent, + printed: this.printed, showTimestamp: this.showTimestamp, timeNow: this.timeNowVal, meta: { ...this.metaData }, @@ -896,6 +906,7 @@ export class BaseLog { this.expression = data.expression; this.dumpContext = data.dumpContext; this.isSilent = data.isSilent; + this.printed = data.printed; this.showTimestamp = data.showTimestamp; this.timeNowVal = data.timeNow; this.metaData = { ...data.meta }; diff --git a/src/shed/Shed.ts b/src/shed/Shed.ts index f3e46c19..295eb1ed 100644 --- a/src/shed/Shed.ts +++ b/src/shed/Shed.ts @@ -204,9 +204,13 @@ export class Shed { * Fires any listeners that are watching the log level defined in the provided log data. The log data * and render object will be passed to the listener callback. */ - public fireListeners(log: FinalLogData, render: LogRender | null): void { + public fireListeners( + log: FinalLogData, + render: LogRender | null, + printed: boolean + ): void { this.listeners.get(log.level)?.forEach((listener) => { - listener(log, render); + listener(log, render, printed); }); } diff --git a/test/adze.ts b/test/adze.ts index 327236cf..67cf1467 100644 --- a/test/adze.ts +++ b/test/adze.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { passesFilters } from '../src/conditions'; -import { adze, defaults, isFinalLogData } from '../src'; +import adze, { defaults, isFinalLogData } from '../src'; import { Defaults, LogLevelDefinition } from '../src/_contracts'; global.ADZE_ENV = 'dev'; @@ -43,21 +43,23 @@ test('create a new logger with defaults', (t) => { t.is(cfg.filters.hideAll, defaults.filters.hideAll); }); -test('prevents log render when the log level is lowered', (t) => { +test('prevents log from printing when the log level is lowered', (t) => { const terminated = adze({ logLevel: 5 }).log('testing'); t.truthy(terminated.log); - t.is(terminated.render, null); + t.truthy(terminated.render); + t.falsy(terminated.printed); }); -test('prevents log render when in a test environment', (t) => { +test('prevents log from printing when in a test environment', (t) => { global.ADZE_ENV = 'test'; const terminated = adze().log('testing'); t.truthy(terminated.log); - t.is(terminated.render, null); + t.truthy(terminated.render); + t.falsy(terminated.printed); global.ADZE_ENV = 'dev'; }); -test('passesFilters correctly indicates that a log is allowed to render', (t) => { +test('passesFilters correctly indicates that a log is allowed to print', (t) => { const { log } = adze({ filters: { hideAll: true, @@ -76,7 +78,7 @@ test('passesFilters correctly indicates that a log is allowed to render', (t) => } }); -test('hideAll global log filter prevents all logs rendering', (t) => { +test('hideAll global log filter prevents all logs printing', (t) => { const cfg = { filters: { hideAll: true, @@ -85,25 +87,25 @@ test('hideAll global log filter prevents all logs rendering', (t) => { const log = adze(cfg).seal(); - const { render: a_render } = log().alert('This is an alert!'); - const { render: e_render } = log().error('This is an error!'); - const { render: w_render } = log().warn('This is a warn!'); - const { render: i_render } = log().info('This is an info!'); - const { render: f_render } = log().fail('This is a failure!'); - const { render: s_render } = log().success('This is a success!'); - const { render: l_render } = log().log('This is a log!'); - const { render: d_render } = log().debug('This is a debug!'); - const { render: v_render } = log().verbose('This is a verbose!'); - - t.falsy(a_render); - t.falsy(e_render); - t.falsy(w_render); - t.falsy(i_render); - t.falsy(f_render); - t.falsy(s_render); - t.falsy(l_render); - t.falsy(d_render); - t.falsy(v_render); + const { printed: a_printed } = log().alert('This is an alert!'); + const { printed: e_printed } = log().error('This is an error!'); + const { printed: w_printed } = log().warn('This is a warn!'); + const { printed: i_printed } = log().info('This is an info!'); + const { printed: f_printed } = log().fail('This is a failure!'); + const { printed: s_printed } = log().success('This is a success!'); + const { printed: l_printed } = log().log('This is a log!'); + const { printed: d_printed } = log().debug('This is a debug!'); + const { printed: v_printed } = log().verbose('This is a verbose!'); + + t.falsy(a_printed); + t.falsy(e_printed); + t.falsy(w_printed); + t.falsy(i_printed); + t.falsy(f_printed); + t.falsy(s_printed); + t.falsy(l_printed); + t.falsy(d_printed); + t.falsy(v_printed); }); test('global filter excludes logs based on label', (t) => { @@ -117,25 +119,25 @@ test('global filter excludes logs based on label', (t) => { const log = adze(cfg).seal(); - const { render: a_render } = log().alert('This is an alert!'); - const { render: e_render } = log().label('test').error('This is an error!'); - const { render: w_render } = log().warn('This is a warn!'); - const { render: i_render } = log().label('test').info('This is an info!'); - const { render: f_render } = log().fail('This is a failure!'); - const { render: s_render } = log().success('This is a success!'); - const { render: l_render } = log().label('test2').log('This is a log!'); - const { render: d_render } = log().label('test2').debug('This is a debug!'); - const { render: v_render } = log().verbose('This is a verbose!'); - - t.truthy(a_render); - t.falsy(e_render); - t.truthy(w_render); - t.falsy(i_render); - t.truthy(f_render); - t.truthy(s_render); - t.falsy(l_render); - t.falsy(d_render); - t.truthy(v_render); + const { printed: a_printed } = log().alert('This is an alert!'); + const { printed: e_printed } = log().label('test').error('This is an error!'); + const { printed: w_printed } = log().warn('This is a warn!'); + const { printed: i_printed } = log().label('test').info('This is an info!'); + const { printed: f_printed } = log().fail('This is a failure!'); + const { printed: s_printed } = log().success('This is a success!'); + const { printed: l_printed } = log().label('test2').log('This is a log!'); + const { printed: d_printed } = log().label('test2').debug('This is a debug!'); + const { printed: v_printed } = log().verbose('This is a verbose!'); + + t.truthy(a_printed); + t.falsy(e_printed); + t.truthy(w_printed); + t.falsy(i_printed); + t.truthy(f_printed); + t.truthy(s_printed); + t.falsy(l_printed); + t.falsy(d_printed); + t.truthy(v_printed); }); test('global filter includes logs based on label', (t) => { @@ -149,25 +151,25 @@ test('global filter includes logs based on label', (t) => { const log = adze(cfg).seal(); - const { render: a_render } = log().alert('This is an alert!'); - const { render: e_render } = log().label('test').error('This is an error!'); - const { render: w_render } = log().warn('This is a warn!'); - const { render: i_render } = log().label('test').info('This is an info!'); - const { render: f_render } = log().fail('This is a failure!'); - const { render: s_render } = log().success('This is a success!'); - const { render: l_render } = log().label('test2').log('This is a log!'); - const { render: d_render } = log().label('test2').debug('This is a debug!'); - const { render: v_render } = log().verbose('This is a verbose!'); - - t.falsy(a_render); - t.truthy(e_render); - t.falsy(w_render); - t.truthy(i_render); - t.falsy(f_render); - t.falsy(s_render); - t.truthy(l_render); - t.truthy(d_render); - t.falsy(v_render); + const { printed: a_printed } = log().alert('This is an alert!'); + const { printed: e_printed } = log().label('test').error('This is an error!'); + const { printed: w_printed } = log().warn('This is a warn!'); + const { printed: i_printed } = log().label('test').info('This is an info!'); + const { printed: f_printed } = log().fail('This is a failure!'); + const { printed: s_printed } = log().success('This is a success!'); + const { printed: l_printed } = log().label('test2').log('This is a log!'); + const { printed: d_printed } = log().label('test2').debug('This is a debug!'); + const { printed: v_printed } = log().verbose('This is a verbose!'); + + t.falsy(a_printed); + t.truthy(e_printed); + t.falsy(w_printed); + t.truthy(i_printed); + t.falsy(f_printed); + t.falsy(s_printed); + t.truthy(l_printed); + t.truthy(d_printed); + t.falsy(v_printed); }); test('global filter excludes logs based on namespace', (t) => { @@ -181,27 +183,27 @@ test('global filter excludes logs based on namespace', (t) => { const log = adze(cfg).seal(); - const { render: a_render } = log().alert('This is an alert!'); - const { render: e_render } = log().ns('testWOW').error('This is an error!'); - const { render: w_render } = log().warn('This is a warn!'); - const { render: i_render } = log().ns('testWOW').info('This is an info!'); - const { render: f_render } = log().fail('This is a failure!'); - const { render: s_render } = log().success('This is a success!'); - const { render: l_render } = log() + const { printed: a_printed } = log().alert('This is an alert!'); + const { printed: e_printed } = log().ns('testWOW').error('This is an error!'); + const { printed: w_printed } = log().warn('This is a warn!'); + const { printed: i_printed } = log().ns('testWOW').info('This is an info!'); + const { printed: f_printed } = log().fail('This is a failure!'); + const { printed: s_printed } = log().success('This is a success!'); + const { printed: l_printed } = log() .ns(['testWOW', 'test2']) .log('This is a log!'); - const { render: d_render } = log().ns('test2').debug('This is a debug!'); - const { render: v_render } = log().verbose('This is a verbose!'); - - t.truthy(a_render); - t.falsy(e_render); - t.truthy(w_render); - t.falsy(i_render); - t.truthy(f_render); - t.truthy(s_render); - t.falsy(l_render); - t.truthy(d_render); - t.truthy(v_render); + const { printed: d_printed } = log().ns('test2').debug('This is a debug!'); + const { printed: v_printed } = log().verbose('This is a verbose!'); + + t.truthy(a_printed); + t.falsy(e_printed); + t.truthy(w_printed); + t.falsy(i_printed); + t.truthy(f_printed); + t.truthy(s_printed); + t.falsy(l_printed); + t.truthy(d_printed); + t.truthy(v_printed); }); test('global filter includes logs based on namespace', (t) => { @@ -215,25 +217,25 @@ test('global filter includes logs based on namespace', (t) => { const log = adze(cfg).seal(); - const { render: a_render } = log().alert('This is an alert!'); - const { render: e_render } = log().ns('test').error('This is an error!'); - const { render: w_render } = log().warn('This is a warn!'); - const { render: i_render } = log().ns('test').info('This is an info!'); - const { render: f_render } = log().fail('This is a failure!'); - const { render: s_render } = log().success('This is a success!'); - const { render: l_render } = log() + const { printed: a_printed } = log().alert('This is an alert!'); + const { printed: e_printed } = log().ns('test').error('This is an error!'); + const { printed: w_printed } = log().warn('This is a warn!'); + const { printed: i_printed } = log().ns('test').info('This is an info!'); + const { printed: f_printed } = log().fail('This is a failure!'); + const { printed: s_printed } = log().success('This is a success!'); + const { printed: l_printed } = log() .ns(['test', 'test2']) .log('This is a log!'); - const { render: d_render } = log().ns('test2').debug('This is a debug!'); - const { render: v_render } = log().verbose('This is a verbose!'); - - t.falsy(a_render); - t.truthy(e_render); - t.falsy(w_render); - t.truthy(i_render); - t.falsy(f_render); - t.falsy(s_render); - t.truthy(l_render); - t.falsy(d_render); - t.falsy(v_render); + const { printed: d_printed } = log().ns('test2').debug('This is a debug!'); + const { printed: v_printed } = log().verbose('This is a verbose!'); + + t.falsy(a_printed); + t.truthy(e_printed); + t.falsy(w_printed); + t.truthy(i_printed); + t.falsy(f_printed); + t.falsy(s_printed); + t.truthy(l_printed); + t.falsy(d_printed); + t.falsy(v_printed); }); diff --git a/test/browser/customize.ts b/test/browser/customize.ts index e5d16007..a30bcc24 100644 --- a/test/browser/customize.ts +++ b/test/browser/customize.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, defaults } from '../../src'; +import adze, { defaults } from '../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/defaults-emoji.ts b/test/browser/defaults-emoji.ts index d6206576..52843d53 100644 --- a/test/browser/defaults-emoji.ts +++ b/test/browser/defaults-emoji.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, defaults } from '../../src'; +import adze, { defaults } from '../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/defaults.ts b/test/browser/defaults.ts index 26294397..c96ea877 100644 --- a/test/browser/defaults.ts +++ b/test/browser/defaults.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, defaults } from '../../src'; +import adze, { defaults } from '../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/modifiers/conditional.ts b/test/browser/modifiers/conditional.ts index b0f8a824..a2f4cd3b 100644 --- a/test/browser/modifiers/conditional.ts +++ b/test/browser/modifiers/conditional.ts @@ -2,7 +2,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, defaults } from '../../../src'; +import adze, { defaults } from '../../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/modifiers/counting.ts b/test/browser/modifiers/counting.ts index 449fc765..dd2c5dca 100644 --- a/test/browser/modifiers/counting.ts +++ b/test/browser/modifiers/counting.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, createShed, removeShed } from '../../../src'; +import adze, { createShed, removeShed } from '../../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/modifiers/grouping.ts b/test/browser/modifiers/grouping.ts index f0d169c4..088c342f 100644 --- a/test/browser/modifiers/grouping.ts +++ b/test/browser/modifiers/grouping.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, defaults } from '../../../src'; +import adze, { defaults } from '../../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/modifiers/identifying.ts b/test/browser/modifiers/identifying.ts index fea82ed5..d2977a96 100644 --- a/test/browser/modifiers/identifying.ts +++ b/test/browser/modifiers/identifying.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze } from '../../../src'; +import adze from '../../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/modifiers/mdc.ts b/test/browser/modifiers/mdc.ts index cc2db5a9..97905dbf 100644 --- a/test/browser/modifiers/mdc.ts +++ b/test/browser/modifiers/mdc.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const browserEnv = require('browser-env'); import test from 'ava'; -import { adze, createShed, removeShed } from '../../../src'; +import adze, { createShed, removeShed } from '../../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/browser/modifiers/timing.ts b/test/browser/modifiers/timing.ts index 8a4e335d..059ee621 100644 --- a/test/browser/modifiers/timing.ts +++ b/test/browser/modifiers/timing.ts @@ -2,7 +2,7 @@ const browserEnv = require('browser-env'); import test from 'ava'; import { formatISO } from 'date-fns'; -import { adze, createShed, removeShed } from '../../../src'; +import adze, { createShed, removeShed } from '../../../src'; // Simulate the browser environment for testing browserEnv(); diff --git a/test/bundle.ts b/test/bundle.ts index b8bf91ca..ec7097fb 100644 --- a/test/bundle.ts +++ b/test/bundle.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, bundle, createShed, removeShed } from '../src'; +import adze, { bundle, createShed, removeShed } from '../src'; global.ADZE_ENV = 'dev'; diff --git a/test/filters.ts b/test/filters.ts index d804dca5..65cd1792 100644 --- a/test/filters.ts +++ b/test/filters.ts @@ -1,6 +1,5 @@ import test from 'ava'; -import { - adze, +import adze, { bundle, filterNamespace, filterLabel, diff --git a/test/formatting.ts b/test/formatting.ts index afdd4976..3eac96eb 100644 --- a/test/formatting.ts +++ b/test/formatting.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze } from '../src'; +import adze from '../src'; global.ADZE_ENV = 'dev'; diff --git a/test/grouping.ts b/test/grouping.ts index 3b77cda9..4ddeab07 100644 --- a/test/grouping.ts +++ b/test/grouping.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze } from '../src'; +import adze from '../src'; // Our global context is the window not global global.ADZE_ENV = 'dev'; diff --git a/test/identifying.ts b/test/identifying.ts index 1914405f..01a5485e 100644 --- a/test/identifying.ts +++ b/test/identifying.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, createShed, removeShed } from '../src'; +import adze, { createShed, removeShed } from '../src'; global.ADZE_ENV = 'dev'; diff --git a/test/mdc.ts b/test/mdc.ts index 36257a3e..cb506675 100644 --- a/test/mdc.ts +++ b/test/mdc.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, createShed, removeShed } from '../src'; +import adze, { createShed, removeShed } from '../src'; global.ADZE_ENV = 'dev'; diff --git a/test/meta.ts b/test/meta.ts index 66e8b9aa..0a807065 100644 --- a/test/meta.ts +++ b/test/meta.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze } from '../src'; +import adze from '../src'; global.ADZE_ENV = 'dev'; diff --git a/test/node/customize.ts b/test/node/customize.ts index d60c794a..55fdea33 100644 --- a/test/node/customize.ts +++ b/test/node/customize.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, ChalkStyle } from '../../src'; +import adze, { ChalkStyle } from '../../src'; import { applyChalkStyles } from '../../src/util'; global.ADZE_ENV = 'dev'; diff --git a/test/node/defaults-emoji.ts b/test/node/defaults-emoji.ts index 2a730a0b..86a774e6 100644 --- a/test/node/defaults-emoji.ts +++ b/test/node/defaults-emoji.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, defaults } from '../../src'; +import adze, { defaults } from '../../src'; import { applyChalkStyles } from '../../src/util'; global.ADZE_ENV = 'dev'; diff --git a/test/node/defaults.ts b/test/node/defaults.ts index 770c598c..0d71a46d 100644 --- a/test/node/defaults.ts +++ b/test/node/defaults.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, ChalkStyle, defaults } from '../../src'; +import adze, { ChalkStyle, defaults } from '../../src'; import { applyChalkStyles } from '../../src/util'; global.ADZE_ENV = 'dev'; diff --git a/test/node/modifiers/conditional.ts b/test/node/modifiers/conditional.ts index 0b382fc1..9234476e 100644 --- a/test/node/modifiers/conditional.ts +++ b/test/node/modifiers/conditional.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, defaults } from '../../../src'; +import adze, { defaults } from '../../../src'; import { applyChalkStyles } from '../../../src/util'; global.ADZE_ENV = 'dev'; diff --git a/test/node/modifiers/counting.ts b/test/node/modifiers/counting.ts index f62aed9f..493b7a7f 100644 --- a/test/node/modifiers/counting.ts +++ b/test/node/modifiers/counting.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, createShed, removeShed } from '../../../src'; +import adze, { createShed, removeShed } from '../../../src'; global.ADZE_ENV = 'dev'; diff --git a/test/node/modifiers/grouping.ts b/test/node/modifiers/grouping.ts index 53eeccad..5bc1aa46 100644 --- a/test/node/modifiers/grouping.ts +++ b/test/node/modifiers/grouping.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, defaults } from '../../../src'; +import adze, { defaults } from '../../../src'; import { applyChalkStyles } from '../../../src/util'; global.ADZE_ENV = 'dev'; diff --git a/test/node/modifiers/identifying.ts b/test/node/modifiers/identifying.ts index e1f4af98..cf4d88e7 100644 --- a/test/node/modifiers/identifying.ts +++ b/test/node/modifiers/identifying.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze } from '../../../src'; +import adze from '../../../src'; global.ADZE_ENV = 'dev'; diff --git a/test/node/modifiers/mdc.ts b/test/node/modifiers/mdc.ts index 8f498ad3..9cd0db9f 100644 --- a/test/node/modifiers/mdc.ts +++ b/test/node/modifiers/mdc.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, createShed, removeShed } from '../../../src'; +import adze, { createShed, removeShed } from '../../../src'; global.ADZE_ENV = 'dev'; diff --git a/test/node/modifiers/timing.ts b/test/node/modifiers/timing.ts index 003817c5..6bbfe326 100644 --- a/test/node/modifiers/timing.ts +++ b/test/node/modifiers/timing.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { formatISO } from 'date-fns'; -import { adze, createShed, removeShed } from '../../../src'; +import adze, { createShed, removeShed } from '../../../src'; global.ADZE_ENV = 'dev'; diff --git a/test/seal.ts b/test/seal.ts index c8295991..9f1698f7 100644 --- a/test/seal.ts +++ b/test/seal.ts @@ -1,5 +1,5 @@ import test from 'ava'; -import { adze, createShed, removeShed } from '../src'; +import adze, { createShed, removeShed } from '../src'; // Our global context is the window not global global.ADZE_ENV = 'dev'; diff --git a/test/shed.ts b/test/shed.ts index edd4b842..7a594ac8 100644 --- a/test/shed.ts +++ b/test/shed.ts @@ -1,8 +1,7 @@ import anyTest, { TestInterface } from 'ava'; import { Shed } from '../src/shed/Shed'; -import { +import adze, { createShed, - adze, removeShed, shedExists, isFinalLogData, @@ -189,7 +188,7 @@ test('removes a log listener', (t) => { }); test('fires the log listeners', (t) => { - const { log, render } = adze().info('A basic log.'); + const { log, render, printed } = adze().info('A basic log.'); const shed = createShed(); shed.addListener([3], () => { @@ -198,7 +197,7 @@ test('fires the log listeners', (t) => { const data = log.data; if (isFinalLogData(data)) { - shed.fireListeners(data, render); + shed.fireListeners(data, render, printed); } else { t.fail(); }