mirror of
https://github.com/codex-team/editor.js
synced 2024-06-02 22:12:27 +02:00
Logger improved (#521)
* Logger styles improved Resolves #520 * increment version * update bundle * change last log
This commit is contained in:
parent
bcdfcdadbc
commit
09df079509
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "codex.editor",
|
"name": "codex.editor",
|
||||||
"version": "2.5.0",
|
"version": "2.5.1",
|
||||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||||
"main": "build/codex-editor.js",
|
"main": "build/codex-editor.js",
|
||||||
"types": "./types/index.d.ts",
|
"types": "./types/index.d.ts",
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default class Core {
|
||||||
await this.init();
|
await this.init();
|
||||||
await this.start();
|
await this.start();
|
||||||
|
|
||||||
_.log('I\'m ready! (ノ◕ヮ◕)ノ*:・゚✧');
|
_.log('I\'m ready! (ノ◕ヮ◕)ノ*:・゚✧', 'log', '', 'color: #E24A75');
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
/**
|
/**
|
||||||
|
@ -230,14 +230,14 @@ export default class Core {
|
||||||
|
|
||||||
await modulesToPrepare.reduce(
|
await modulesToPrepare.reduce(
|
||||||
(promise, module) => promise.then(async () => {
|
(promise, module) => promise.then(async () => {
|
||||||
_.log(`Preparing ${module} module`, 'time');
|
// _.log(`Preparing ${module} module`, 'time');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.moduleInstances[module].prepare();
|
await this.moduleInstances[module].prepare();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_.log(`Module ${module} was skipped because of %o`, 'warn', e);
|
_.log(`Module ${module} was skipped because of %o`, 'warn', e);
|
||||||
}
|
}
|
||||||
_.log(`Preparing ${module} module`, 'timeEnd');
|
// _.log(`Preparing ${module} module`, 'timeEnd');
|
||||||
}),
|
}),
|
||||||
Promise.resolve(),
|
Promise.resolve(),
|
||||||
);
|
);
|
||||||
|
@ -262,7 +262,7 @@ export default class Core {
|
||||||
config : this.configuration,
|
config : this.configuration,
|
||||||
});
|
});
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
console.log('Module %o skipped because %o', Module, e);
|
_.log(`Module ${Module.displayName} skipped because`, 'warn', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
import Dom from './dom';
|
import Dom from './dom';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow to use global VERSION, that will be overwritten by Webpack
|
||||||
|
*/
|
||||||
|
declare const VERSION: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ChainData
|
* @typedef {Object} ChainData
|
||||||
* @property {Object} data - data that will be passed to the success or fallback
|
* @property {Object} data - data that will be passed to the success or fallback
|
||||||
|
@ -23,28 +28,36 @@ export default class Util {
|
||||||
*
|
*
|
||||||
* @param {string} msg - message
|
* @param {string} msg - message
|
||||||
* @param {string} type - logging type 'log'|'warn'|'error'|'info'
|
* @param {string} type - logging type 'log'|'warn'|'error'|'info'
|
||||||
* @param {*} args - argument to log with a message
|
* @param {*} [args] - argument to log with a message
|
||||||
|
* @param {string} style - additional styling to message
|
||||||
*/
|
*/
|
||||||
public static log(msg: string, type: string = 'log', args?: any): void {
|
public static log(msg: string, type: string = 'log', args?: any, style: string = 'color: inherit'): void {
|
||||||
|
|
||||||
if (!args) {
|
if ( !('console' in window) || !window.console[ type ] ) {
|
||||||
if (['time', 'timeEnd'].includes(type)) {
|
return;
|
||||||
msg = `[codex-editor]: ${msg}`;
|
|
||||||
} else {
|
|
||||||
args = msg || 'undefined';
|
|
||||||
msg = '[codex-editor]: %o';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
msg = '[codex-editor]: ' + msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const editorLabelText = `Editor.js ${VERSION}`;
|
||||||
|
const editorLabelStyle = `line-height: 1em;
|
||||||
|
color: #006FEA;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1em;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 4px 9px;
|
||||||
|
border-radius: 30px;
|
||||||
|
border: 1px solid rgba(56, 138, 229, 0.16);
|
||||||
|
margin: 4px 5px 4px 0;`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( 'console' in window && window.console[ type ] ) {
|
if (['time', 'timeEnd'].includes(type)) {
|
||||||
if ( args ) { window.console[ type ]( msg, args ); } else { window.console[ type ]( msg ); }
|
console[type](`( ${editorLabelText} ) ${msg}`);
|
||||||
|
} else if (args) {
|
||||||
|
console[type](`%c${editorLabelText}%c ${msg} %o`, editorLabelStyle, style, args);
|
||||||
|
} else {
|
||||||
|
console[type](`%c${editorLabelText}%c ${msg}`, editorLabelStyle, style);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (ignored) {}
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue