Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enabled deep-merging between default & custom types #31

Merged
merged 1 commit into from
May 31, 2018

Conversation

klaudiosinani
Copy link
Owner

@klaudiosinani klaudiosinani commented May 31, 2018

This PR enables the selective override of user-specified attributes on the default loggers, by deep merging the custom logger types against the default ones, and preserving the values of all unmodified attributes, e.g:

// example.js
const {Signale} = require('signale');

const options = {
  types: {
    error: {
      // Here `yellow` will override only the default `red` color 
      // and all other default attributes will stay unmodified
      color: 'yellow'
    }
  }
};

const signale = new Signale(options);
console.log(signale._types);

The error type logger will now hold the following expected attributes:

{
  // ...
  error: {
    badge: '✖',
    color: 'yellow',
    label: 'error'
  },
  // ...
}

Currently, error receives only the color attribute, losing all other default ones:

{
  // ...
  error: {
    color: 'yellow'
  },
  // ...
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant