From 62716422b9f57b11f3a0afb01f5011b63702226d Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 18 Mar 2021 19:25:25 +0100 Subject: chore(console): distinguish between log levels (#9824) Change `Console.#printFunc` to pass a log level as the second argument (0 = debug, 3 = error), instead of a boolean for `isErr`. This does not change the Deno runtime behaviour at all. --- op_crates/console/02_console.js | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'op_crates/console/02_console.js') diff --git a/op_crates/console/02_console.js b/op_crates/console/02_console.js index 0077571a6..587ec0ec2 100644 --- a/op_crates/console/02_console.js +++ b/op_crates/console/02_console.js @@ -1505,18 +1505,35 @@ ...getConsoleInspectOptions(), indentLevel: this.indentLevel, }) + "\n", - false, + 1, ); }; - debug = this.log; - info = this.log; + debug = (...args) => { + this.#printFunc( + inspectArgs(args, { + ...getConsoleInspectOptions(), + indentLevel: this.indentLevel, + }) + "\n", + 0, + ); + }; + + info = (...args) => { + this.#printFunc( + inspectArgs(args, { + ...getConsoleInspectOptions(), + indentLevel: this.indentLevel, + }) + "\n", + 1, + ); + }; dir = (obj, options = {}) => { this.#printFunc( inspectArgs([obj], { ...getConsoleInspectOptions(), ...options }) + "\n", - false, + 1, ); }; @@ -1528,11 +1545,19 @@ ...getConsoleInspectOptions(), indentLevel: this.indentLevel, }) + "\n", - true, + 2, ); }; - error = this.warn; + error = (...args) => { + this.#printFunc( + inspectArgs(args, { + ...getConsoleInspectOptions(), + indentLevel: this.indentLevel, + }) + "\n", + 3, + ); + }; assert = (condition = false, ...args) => { if (condition) { @@ -1724,8 +1749,8 @@ clear = () => { this.indentLevel = 0; - this.#printFunc(CSI.kClear, false); - this.#printFunc(CSI.kClearScreenDown, false); + this.#printFunc(CSI.kClear, 1); + this.#printFunc(CSI.kClearScreenDown, 1); }; trace = (...args) => { -- cgit v1.2.3