-
Notifications
You must be signed in to change notification settings - Fork 19
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
Disable log_color programatically #65
Comments
The tutorial contains a section about enabling and disabling log colors. The command should be ulog.set('color', 'off') The reason for this is that if you change settings programmatically, you use the setting name ( Also, if you want to get rid of colors all together, you could just remove the |
Also, when you set settings programmatically, you effectively override config. I recommend against it. Basically it's there for testing purposes. You can remove your override with |
I am developing an app which is used by non-programmers. So, a user may rarely start the app with |
If you want to override the default config (as opposed to hardcode set the setting), I suggest making a small mod that only overrides the default value. The default value in the absence of config is determined by a property module.exports = {
use: [
require('../channels'),
],
settings: {
format: {
config: 'log_format',
prop: {
default: require('./default'),
}
},
}, https://github.com/Download/ulog/blob/master/mods/formats/index.js#L24 (the value is stored in the file default.js, or default.browser.js, depending on platform) To override this default, you could make a mod like this: var ulog = require('ulog')
var changeDefault = {
use: require('ulog/mods/formats'),
settings: {
format: {
prop: {
default: 'My new default format! :)',
}
}
}
}
ulog.use(changeDefault) Do this before using ulog, so in your entry point somewhere. This gives you a new default format without breaking the option to use config to set it later. |
Yes, that's what I have tried with color but failed, because I have missed the settings: {
colored: {
config: 'log_color',
prop: boolean(),
},
}, It's working now, thanks. |
Glad you worked it out!
I guess you are referring to the module.exports = function(prop) {
var result = {
default: 'on',
// ... https://github.com/Download/ulog/blob/master/mods/props/boolean.js#L5 Could you maybe suggest a (documentation / code) change that would have helped you more easily understand? Would it have been better if the code would have looked like this: settings: {
colored: {
config: 'log_color',
prop: boolean({
default: 'on',
}),
},
}, I think it's also unnatural for booleans to default to Feedback? |
Yes, it may help reading the code. I think general expectation is that the Maybe also add similar case to https://github.com/Download/ulog#mods |
Yes, good points. Let me keep this issue open for a bit longer so I can address these. |
ulog
version: 2.0.0-beta.18I cannot disable
log_color
programmatically for all loggers. I have triedBut if I create a logger afterwards
const log = ulog("my")
, it logs with colors. (Same withlog_align
).Note: disabling or excluding whole
colors
mod would be also fine.The text was updated successfully, but these errors were encountered: