logdown.js icon indicating copy to clipboard operation
logdown.js copied to clipboard

Support global Logdown options

Open bennycode opened this issue 8 years ago • 2 comments

It would be nice if you could set a preset for every newly created Logdown instance.

Example:

If I always want to have logger instances which don't render Markdown but align output, I should be able to do something like this:

Logdown.preset({
  alignOuput: true,
  markdown: false
});

var firstLogger = new Logdown({prefix: 'firstLogger'});
var secondLogger = new Logdown({prefix: 'secondLogger'});

This should be equivalent to:

var firstLogger = new Logdown({
  prefix: 'firstLogger',
  alignOuput: true,
  markdown: false
});

var secondLogger = new Logdown({
  prefix: 'secondLogger',
  alignOuput: true,
  markdown: false
});

bennycode avatar Dec 22 '16 22:12 bennycode

I like the idea.

But we should have a getter and setter for this.

What you think about just exposing an object?

Logdown.opts = {
  alignOutput: true,
  markdown: false
}

Then to change it, you could do:

Logdown.opts.markdown = false

// or

Logdown.opts = Object.assign({}, Logdown.opts, {markdown: true})

Feels more idiomatic

And on https://github.com/caiogondim/logdown.js/blob/master/src/index.js#L62 we just do Object.assign before creating a new object.

caiogondim avatar Dec 23 '16 12:12 caiogondim

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 10 '17 21:10 stale[bot]