Logger Extension #1449
-
Hola!I want to find out if it is possible to redefine the logger in version 4. At the moment, I can configure the logger as follows:const sd = new StyleDictionary({
...
log: {
warnings: logWarningLevels.warn, // 'warn' | 'error' | 'disabled'
verbosity: logVerbosityLevels.default, // 'default' | 'silent' | 'verbose'
errors: {
brokenReferences: logBrokenReferenceLevels.throw, // 'throw' | 'console'
},
},
}); As described in the documentation. But I'm wondering if I can control the behavior/override the behavior of the logger? For example, as follows:const logger = {
log: (message) => {
fs.appendFileSync('default.log', `${message}\n`);
},
warn: (message) => {
fs.appendFileSync('warnings.log', `WARNING: ${message}\n`);
},
error: (message) => {
fs.appendFileSync('errors.log', `ERROR: ${message}\n`);
},
};
const sd = new StyleDictionary({
...
log: logger
}); I will be grateful for the answer! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
No not currently, but I'd definitely be open to adding a new hook "logger" that you can register ( |
Beta Was this translation helpful? Give feedback.
No not currently, but I'd definitely be open to adding a new hook "logger" that you can register (
registerLogger({...})
) or use inline in the config.I also like the idea of callback messages for logging/warning/erroring. For errors it would call the callback before throwing, so the callback completes before the program exits. I think they should support async callbacks as well.
It would be a pretty significant feature to contribute but if someone is willing to try that would be cool.