Skip to content

Commit 884975c

Browse files
committed
feat(logs): Refactor logs for plugin_manager
1 parent 3881544 commit 884975c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

core/lib/plugin_manager.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const plugin_manager = function (config, configPath) {
44
const path = require('path');
55
const fs = require('fs-extra');
6-
const util = require('./utilities');
6+
const logger = require('./log');
77

88
/**
99
* Loads a plugin
@@ -25,12 +25,12 @@ const plugin_manager = function (config, configPath) {
2525
const pluginPath = path.resolve(
2626
path.join(process.cwd(), 'node_modules', pluginName)
2727
);
28-
console.log('Attempting to load plugin from', pluginPath);
28+
logger.debug(`Attempting to load plugin from ${pluginPath}`);
2929
try {
3030
var pluginDirStats = fs.statSync(pluginPath);
3131
} catch (ex) {
32-
util.error(pluginName + ' not found, please use npm to install it first.');
33-
util.error(pluginName + ' not loaded.');
32+
logger.warning(`${pluginName} not found, use npm to install it first.`);
33+
logger.warning(`${pluginName} not loaded.`);
3434
return;
3535
}
3636
const pluginPathDirExists = pluginDirStats.isDirectory();
@@ -63,13 +63,12 @@ const plugin_manager = function (config, configPath) {
6363
//write config entry back
6464
fs.outputFileSync(path.resolve(configPath), JSON.stringify(diskConfig, null, 2));
6565

66-
util.debug('Plugin ' + pluginName + ' installed.');
67-
68-
//todo, tell them how to uninstall or disable
69-
66+
logger.info('Plugin ' + pluginName + ' installed.');
67+
logger.info('Plugin configration added to patternlab-config.json.');
7068
}
7169
} catch (ex) {
72-
console.log(ex);
70+
logger.warning(`An error occurred during plugin installation for plugin ${pluginName}`);
71+
logger.warning(ex);
7372
}
7473
}
7574

@@ -91,15 +90,15 @@ const plugin_manager = function (config, configPath) {
9190
* Not implemented yet
9291
*/
9392
function disablePlugin(pluginName) {
94-
console.log('disablePlugin not implemented yet. No change made to state of plugin', pluginName);
93+
logger.warning(`disablePlugin() not implemented yet. No change made to state of plugin ${pluginName}`);
9594
}
9695

9796
/**
9897
* Enables an installed plugin
9998
* Not implemented yet
10099
*/
101100
function enablePlugin(pluginName) {
102-
console.log('enablePlugin not implemented yet. No change made to state of plugin', pluginName);
101+
logger.warning(`enablePlugin() not implemented yet. No change made to state of plugin ${pluginName}`);
103102
}
104103

105104
return {

0 commit comments

Comments
 (0)