You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-03 23:50:33 +02:00
All: Added global logger
Avoids having to pass around a logger to every module and sub-module, and makes it easier to set log level globally.
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import Plugin from '../Plugin';
|
||||
import Joplin from './Joplin';
|
||||
import Logger from '../../../Logger';
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
@ -16,8 +15,8 @@ export default class Global {
|
||||
private requireWhiteList_: string[] = null;
|
||||
// private consoleWrapper_:any = null;
|
||||
|
||||
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any) {
|
||||
this.joplin_ = new Joplin(logger, implementation.joplin, plugin, store);
|
||||
constructor(implementation: any, plugin: Plugin, store: any) {
|
||||
this.joplin_ = new Joplin(implementation.joplin, plugin, store);
|
||||
// this.consoleWrapper_ = this.createConsoleWrapper(plugin.id);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import JoplinCommands from './JoplinCommands';
|
||||
import JoplinViews from './JoplinViews';
|
||||
import JoplinInterop from './JoplinInterop';
|
||||
import JoplinSettings from './JoplinSettings';
|
||||
import Logger from '../../../Logger';
|
||||
|
||||
/**
|
||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||
@ -35,9 +34,9 @@ export default class Joplin {
|
||||
private interop_: JoplinInterop = null;
|
||||
private settings_: JoplinSettings = null;
|
||||
|
||||
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any) {
|
||||
constructor(implementation: any, plugin: Plugin, store: any) {
|
||||
this.data_ = new JoplinData();
|
||||
this.plugins_ = new JoplinPlugins(logger, plugin);
|
||||
this.plugins_ = new JoplinPlugins(plugin);
|
||||
this.workspace_ = new JoplinWorkspace(implementation.workspace, store);
|
||||
this.filters_ = new JoplinFilters();
|
||||
this.commands_ = new JoplinCommands();
|
||||
|
@ -2,16 +2,16 @@ import Plugin from '../Plugin';
|
||||
import Logger from '../../../Logger';
|
||||
import { ContentScriptType, Script } from './types';
|
||||
|
||||
const logger = Logger.create('joplin.plugins');
|
||||
|
||||
/**
|
||||
* This class provides access to plugin-related features.
|
||||
*/
|
||||
export default class JoplinPlugins {
|
||||
|
||||
private logger: Logger;
|
||||
private plugin: Plugin;
|
||||
|
||||
public constructor(logger: Logger, plugin: Plugin) {
|
||||
this.logger = logger;
|
||||
public constructor(plugin: Plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ export default class JoplinPlugins {
|
||||
if (script.onStart) {
|
||||
const startTime = Date.now();
|
||||
|
||||
this.logger.info(`Starting plugin: ${this.plugin.id}`);
|
||||
logger.info(`Starting plugin: ${this.plugin.id}`);
|
||||
|
||||
// We don't use `await` when calling onStart because the plugin might be awaiting
|
||||
// in that call too (for example, when opening a dialog on startup) so we don't
|
||||
@ -42,9 +42,9 @@ export default class JoplinPlugins {
|
||||
// be handled correctly by loggers, etc.
|
||||
const newError: Error = new Error(error.message);
|
||||
newError.stack = error.stack;
|
||||
this.logger.error(`Uncaught exception in plugin "${this.plugin.id}":`, newError);
|
||||
logger.error(`Uncaught exception in plugin "${this.plugin.id}":`, newError);
|
||||
}).then(() => {
|
||||
this.logger.info(`Finished running onStart handler: ${this.plugin.id} (Took ${Date.now() - startTime}ms)`);
|
||||
logger.info(`Finished running onStart handler: ${this.plugin.id} (Took ${Date.now() - startTime}ms)`);
|
||||
this.plugin.emit('started');
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user