Angular 2 ng2-logger color config

I have set ng2-logger

to render my console.logs better.

https://www.npmjs.com/package/ng2-logger

But the colors are random.

Can I choose the color of my preference for each component or file type? If so, how can this be done? My goal is to have some configuration for ng2-logger

without having to enter a color for each instance.

+3


source to share


1 answer


Yes, you can.

Try to create a vector for your log configuration, for example:

export const LOG_CONFIG: any = {
    app: '#2d2a26',
    filter: '#2e6991',
    table: '#a8353a',
    service: '#ae6d36',
    navigation: '#014822'
};

      

And then just call it like this in your file:

import { Log } from 'ng2-logger';
import { LOG_CONFIG } from 'path/log_config';

const log = Log.create('Table Component);
log.color = LOG_CONFIG.table;

      



This way you produce an instance Log

with a color for each type of file or component.

In my example, I just did it with color, you can do it with text, level and other options ng2-logger

.

Hope this helped!

Hooray!;)

+3


source







All Articles