diff --git a/src/tasks/stdio/log.ts b/src/tasks/stdio/log.ts index 1866d24..6c93f21 100644 --- a/src/tasks/stdio/log.ts +++ b/src/tasks/stdio/log.ts @@ -33,16 +33,14 @@ const color = { * of the call. * @returns Task */ -export function log( - level: Exclude, - item: any, - ...data: any[] -): Task.Sync { - const nLevel = rank[String(level).toLowerCase()] || 5; +export function log(level: LogLevel, item: any, ...data: any[]): Task.Sync { + level = String(level) as LogLevel; + const nLevel = rank[level.toLowerCase()] || 5; return (ctx: Context): void => { - const nCurrent = rank[String(ctx.level).toLowerCase()] || 0; + if (level === 'silent' || level.toLowerCase() === 'silent') return; + const nCurrent = rank[String(ctx.level).toLowerCase()] || 0; if (nCurrent >= nLevel) { const str = addPrefix( util.format(item, ...data) + '\n', diff --git a/src/tasks/transform/catches.ts b/src/tasks/transform/catches.ts index ccbbc7c..f84b868 100644 --- a/src/tasks/transform/catches.ts +++ b/src/tasks/transform/catches.ts @@ -29,12 +29,8 @@ export function catches( try { await task(ctx); } catch (err) { - if (opts.level !== 'silent') { - into(ctx, log(opts.level, formatMessage(err))); - } - if (alternate) { - await alternate(ctx); - } + into(ctx, log(opts.level, formatMessage(err))); + if (alternate) await alternate(ctx); } }; }