Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Log levels #971

Merged
merged 8 commits into from
Nov 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dist/editor.js

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions dist/editor.licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MIT
MIT License

Copyright (c) 2014-2018 Sebastian McKenzie and other contributors
Copyright (c) 2014-present Sebastian McKenzie and other contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -28,7 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT
MIT License

Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
Copyright (c) 2014-present Sebastian McKenzie and other contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -163,7 +163,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

core-js
MIT
Copyright (c) 2014-2018 Denis Pushkarev
Copyright (c) 2014-2019 Denis Pushkarev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -390,3 +390,24 @@ Apache License

regenerator-runtime
MIT
MIT License

Copyright (c) 2014-present, Facebook, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
— `Improvements` — Module Listeners now correctly removes events with options [#904](https://github.com/codex-team/editor.js/pull/904)
— `Fix` — Fixed History Back on block deletion by Backspace in Firefox [#967](https://github.com/codex-team/editor.js/pull/967)
- `Fix` — Fixed `getRangeCount` call if range count is 0 [#938](https://github.com/codex-team/editor.js/issues/938)
- `New` — Log levels now available to suppress Editor.js console messages [#962](https://github.com/codex-team/editor.js/issues/962)

### 2.15.1

Expand Down
24 changes: 23 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,26 @@ var editor = new EditorJS({

```

If you are using your custom `Initial Block`, `placeholder` property is passed in `config` to your Tool constructor.
If you are using your custom `Initial Block`, `placeholder` property is passed in `config` to your Tool constructor.

## Log level

You can specify log level for Editor.js console messages via `logLevel' property of configuration:

```js
var editor = new EditorJS({
//...
logLevel: 'WARN'
//..
})
```

Possible values:

| Value | Description |
| ----- | ---------------------------- |
| `VERBOSE` | Show all messages |
| `INFO` | Show info and debug messages |
| `WARN` | Show errors and warns only |
| `ERROR` | Show errors only |

2 changes: 1 addition & 1 deletion src/components/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

import {SavedData} from '../types-internal/block-data';
import $ from './dom';
import _ from './utils';
import * as _ from './utils';

/**
* @class Block
Expand Down
2 changes: 1 addition & 1 deletion src/components/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from './utils';
import * as _ from './utils';
import $ from './dom';
import Block, {BlockToolAPI} from './block';

Expand Down
11 changes: 9 additions & 2 deletions src/components/core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import $ from './dom';
import _ from './utils';
import * as _ from './utils';
import {EditorConfig, OutputData, SanitizerConfig} from '../../types';
import {EditorModules} from '../types-internal/editor-modules';
import {LogLevels} from './utils';

/**
* @typedef {Core} Core - editor core class
Expand Down Expand Up @@ -75,7 +76,7 @@ export default class Core {
await this.init();
await this.start();

_.log('I\'m ready! (ノ◕ヮ◕)ノ*:・゚✧', 'log', '', 'color: #E24A75');
_.logLabeled('I\'m ready! (ノ◕ヮ◕)ノ*:・゚✧', 'log', '', 'color: #E24A75');

setTimeout(async () => {
await this.render();
Expand Down Expand Up @@ -144,6 +145,12 @@ export default class Core {
this.config.holder = 'editorjs';
}

if (!this.config.logLevel) {
this.config.logLevel = LogLevels.VERBOSE;
}

_.setLogLevel(this.config.logLevel);

/**
* If initial Block's Tool was not passed, use the Paragraph Tool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/flipper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DomIterator from './domIterator';
import _ from './utils';
import * as _ from './utils';

/**
* Flipper construction options
Expand Down
2 changes: 1 addition & 1 deletion src/components/inline-tools/inline-tool-link.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SelectionUtils from '../selection';

import $ from '../dom';
import _ from '../utils';
import * as _ from '../utils';
import {API, InlineTool, SanitizerConfig} from '../../../types';
import {Notifier, Toolbar} from '../../../types/api';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Module from '../../__module';

import {Blocks} from '../../../../types/api';
import {BlockToolData, OutputData, ToolConfig} from '../../../../types';
import _ from './../../utils';
import * as _ from './../../utils';

/**
* @class BlocksAPI
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/blockEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Contains keyboard and mouse events binded on each Block by Block Manager
*/
import Module from '../__module';
import _ from '../utils';
import * as _ from '../utils';
import SelectionUtils from '../selection';
import Flipper from '../flipper';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/blockManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Block, {BlockToolAPI} from '../block';
import Module from '../__module';
import $ from '../dom';
import _ from '../utils';
import * as _ from '../utils';
import Blocks from '../blocks';
import {BlockTool, BlockToolConstructable, BlockToolData, PasteEvent, ToolConfig} from '../../../types';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/blockSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import Module from '../__module';
import Block from '../block';
import _ from '../utils';
import * as _ from '../utils';
import $ from '../dom';

import SelectionUtils from '../selection';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Selection from '../selection';
import Module from '../__module';
import Block from '../block';
import $ from '../dom';
import _ from '../utils';
import * as _ from '../utils';

/**
* @typedef {Caret} Caret
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/crossBlockSelection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Module from '../__module';
import Block from '../block';
import SelectionUtils from '../selection';
import _ from '../utils';
import * as _ from '../utils';

export default class CrossBlockSelection extends Module {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/modificationsObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import Module from '../__module';
import _ from '../utils';
import * as _ from '../utils';
import Block from '../block';

export default class ModificationsObserver extends Module {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/paste.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Module from '../__module';
import $ from '../dom';
import _ from '../utils';
import * as _ from '../utils';
import {
BlockTool,
BlockToolConstructable,
Expand Down
3 changes: 2 additions & 1 deletion src/components/modules/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Module from '../__module';
import _, {ChainData} from '../utils';
import * as _ from '../utils';
import {ChainData} from '../utils';
import {BlockToolData} from '../../../types';
import {BlockToolConstructable} from '../../../types/tools';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/sanitizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import Module from '../__module';
import _ from '../utils';
import * as _ from '../utils';

/**
* @typedef {Object} SanitizerConfig
Expand Down
17 changes: 9 additions & 8 deletions src/components/modules/saver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Module from '../__module';
import {OutputData} from '../../../types';
import {ValidatedData} from '../../types-internal/block-data';
import Block from '../block';
import * as _ from '../utils';

declare const VERSION: string;

Expand Down Expand Up @@ -67,23 +68,23 @@ export default class Saver extends Module {
let totalTime = 0;
const blocks = [];

console.groupCollapsed('[Editor.js saving]:');
_.log('[Editor.js saving]:', 'groupCollapsed');

allExtractedData.forEach(({tool, data, time, isValid}) => {
totalTime += time;

/**
* Capitalize Tool name
*/
console.group(`${tool.charAt(0).toUpperCase() + tool.slice(1)}`);
_.log(`${tool.charAt(0).toUpperCase() + tool.slice(1)}`, 'group');

if (isValid) {
/** Group process info */
console.log(data);
console.groupEnd();
_.log(data);
_.log(undefined, 'groupEnd');
} else {
console.log(`Block «${tool}» skipped because saved data is invalid`);
console.groupEnd();
_.log(`Block «${tool}» skipped because saved data is invalid`);
_.log(undefined, 'groupEnd');
return;
}

Expand All @@ -99,8 +100,8 @@ export default class Saver extends Module {
});
});

console.log('Total', totalTime);
console.groupEnd();
_.log('Total', 'log', totalTime);
_.log(undefined, 'groupEnd');

return {
time: +new Date(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/toolbar/blockSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Module from '../../__module';
import $ from '../../dom';
import Flipper, {FlipperOptions} from '../../flipper';
import _ from '../../utils';
import * as _ from '../../utils';

/**
* Block Settings
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/toolbar/conversion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Module from '../../__module';
import $ from '../../dom';
import {BlockToolConstructable} from '../../../../types';
import _ from '../../utils';
import * as _ from '../../utils';
import {SavedData} from '../../../types-internal/block-data';
import Block from '../../block';
import Flipper from '../../flipper';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/toolbar/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Module from '../../__module';
import $ from '../../dom';
import _ from '../../utils';
import * as _ from '../../utils';

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/toolbar/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Module from '../../__module';
import $ from '../../dom';

import SelectionUtils from '../../selection';
import _ from '../../utils';
import * as _ from '../../utils';
import {InlineTool, InlineToolConstructable, ToolConstructable, ToolSettings} from '../../../../types';
import Flipper from '../../flipper';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/toolbar/toolbox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Module from '../../__module';
import $ from '../../dom';
import _ from '../../utils';
import * as _ from '../../utils';
import {BlockToolConstructable} from '../../../../types';
import Flipper from '../../flipper';
import {BlockToolAPI} from '../../block';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/tools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Paragraph from '../tools/paragraph/dist/bundle';
import Module from '../__module';
import _ from '../utils';
import * as _ from '../utils';
import {
BlockToolConstructable,
InlineTool,
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sprite from '../../../dist/sprite.svg';
*/
import Module from '../__module';
import $ from '../dom';
import _ from '../utils';
import * as _ from '../utils';

import Selection from '../selection';
import Block from '../block';
Expand Down
2 changes: 1 addition & 1 deletion src/components/selection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* TextRange interface fot IE9-
*/
import _ from './utils';
import * as _ from './utils';
import $ from './dom';

interface TextRange {
Expand Down
Loading