Skip to content

Commit

Permalink
Distinguish between .log() and .logDebug()
Browse files Browse the repository at this point in the history
which now call
  `console.log()` and `console.debug()` respectively.
  • Loading branch information
mar10 committed Jan 20, 2024
1 parent ee131fc commit 5047f31
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ First release.
> This section will be removed after the beta phase. <br>
> 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.
Expand Down
3 changes: 1 addition & 2 deletions src/wb_ext_dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,10 @@ export class DndExtension extends WunderbaumExtension<DndOptionsType> {
/** 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;
Expand Down
21 changes: 14 additions & 7 deletions src/wb_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 15 additions & 8 deletions src/wunderbaum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5047f31

Please sign in to comment.