diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd08a24..d4af2044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,15 @@ First release. > This section will be removed after the beta phase.
> Note that semantic versioning rules are not strictly followed during this phase. +- v0.8.1: Distinguish between `.log()` and `.logDebug()`, which now call + `console.log()` and `console.debug()` respectively. - v0.8.1: Fix #72: DragEnter event does not provide the source node, only the target. - v0.8.1: Fix #73: Fix typing of `tree.options.dnd.dropEffect` and others. - v0.8.1: Fix #75: After reloading nodes with "resetLazy", wunderbaum is broken. - v0.8.1: Fix #76: Lazyload could be called for the same node multiple times. - v0.8.1: Fix #78: Add JS Bin template for reporting issues. - v0.8.1: Fix #79: Improve logging when drop operation is prevented. -- Thanks to @jogibear9988 for the testing, opening, and contributing to all of +- Thanks to @jogibear9988 for the testing, opening, and contributing to most of these issues. - v0.8.0: Add `expand(e)` and `beforeExpand(e)` events. diff --git a/src/wb_ext_dnd.ts b/src/wb_ext_dnd.ts index d549c0d0..32dd71ec 100644 --- a/src/wb_ext_dnd.ts +++ b/src/wb_ext_dnd.ts @@ -371,11 +371,10 @@ export class DndExtension extends WunderbaumExtension { /** Helper to log a message if predicate is false. */ const _t = (pred: any, msg: string) => { if (pred) { - this.tree.logDebug(`Prevented drop operation (${msg}).`); + this.tree.log(`Prevented drop operation (${msg}).`); } return pred; }; - if (!targetNode) { this._leaveNode(); return; diff --git a/src/wb_node.ts b/src/wb_node.ts index cec3eeff..e8c0e29d 100644 --- a/src/wb_node.ts +++ b/src/wb_node.ts @@ -1234,33 +1234,40 @@ export class WunderbaumNode { return; } - /** Alias for `logDebug` */ + /** Write to `console.log` with node name as prefix if opts.debugLevel >= 4. + * @see {@link WunderbaumNode.logDebug} + */ log(...args: any[]) { - this.logDebug(...args); + if (this.tree.options.debugLevel! >= 4) { + console.log(this.toString(), ...args); // eslint-disable-line no-console + } } - /* Log to console if opts.debugLevel >= 4 */ + /** Write to `console.debug` with node name as prefix if opts.debugLevel >= 4 + * and browser console level includes debug/verbose messages. + * @see {@link WunderbaumNode.log} + */ logDebug(...args: any[]) { if (this.tree.options.debugLevel! >= 4) { - console.log(this.toString(), ...args); // eslint-disable-line no-console + console.debug(this.toString(), ...args); // eslint-disable-line no-console } } - /* Log error to console. */ + /** Write to `console.error` with node name as prefix if opts.debugLevel >= 1. */ logError(...args: any[]) { if (this.tree.options.debugLevel! >= 1) { console.error(this.toString(), ...args); // eslint-disable-line no-console } } - /* Log to console if opts.debugLevel >= 3 */ + /** Write to `console.info` with node name as prefix if opts.debugLevel >= 3. */ logInfo(...args: any[]) { if (this.tree.options.debugLevel! >= 3) { console.info(this.toString(), ...args); // eslint-disable-line no-console } } - /* Log warning to console if opts.debugLevel >= 2 */ + /** Write to `console.warn` with node name as prefix if opts.debugLevel >= 2. */ logWarn(...args: any[]) { if (this.tree.options.debugLevel! >= 2) { console.warn(this.toString(), ...args); // eslint-disable-line no-console diff --git a/src/wunderbaum.ts b/src/wunderbaum.ts index eb15179e..317455ae 100644 --- a/src/wunderbaum.ts +++ b/src/wunderbaum.ts @@ -1540,26 +1540,33 @@ export class Wunderbaum { return res; } - /** Alias for {@link Wunderbaum.logDebug}. - * @alias Wunderbaum.logDebug + /** Write to `console.log` with tree name as prefix if opts.debugLevel >= 4. + * @see {@link Wunderbaum.logDebug} */ - log = this.logDebug; + log(...args: any[]) { + if (this.options.debugLevel! >= 4) { + console.log(this.toString(), ...args); // eslint-disable-line no-console + } + } - /** Log to console if opts.debugLevel >= 4 */ + /** Write to `console.debug` with tree name as prefix if opts.debugLevel >= 4. + * and browser console level includes debug/verbose messages. + * @see {@link Wunderbaum.log} + */ logDebug(...args: any[]) { if (this.options.debugLevel! >= 4) { - console.log(this.toString(), ...args); // eslint-disable-line no-console + console.debug(this.toString(), ...args); // eslint-disable-line no-console } } - /** Log error to console. */ + /** Write to `console.error` with tree name as prefix. */ logError(...args: any[]) { if (this.options.debugLevel! >= 1) { console.error(this.toString(), ...args); // eslint-disable-line no-console } } - /** Log to console if opts.debugLevel >= 3 */ + /** Write to `console.info` with tree name as prefix if opts.debugLevel >= 3. */ logInfo(...args: any[]) { if (this.options.debugLevel! >= 3) { console.info(this.toString(), ...args); // eslint-disable-line no-console @@ -1581,7 +1588,7 @@ export class Wunderbaum { } } - /** Log to console if opts.debugLevel >= 2 */ + /** Write to `console.warn` with tree name as prefix with if opts.debugLevel >= 2. */ logWarn(...args: any[]) { if (this.options.debugLevel! >= 2) { console.warn(this.toString(), ...args); // eslint-disable-line no-console