Support RGB colours (similar to chalk)?
pke opened this issue · 3 comments
pke commented
Would it be possible to support RGB colours for the console transport?
I think it should be possible with the help of https://github.com/chalk/ansi-styles
and a colour could be created like styles.color.ansi16m(100,0,0)
pke commented
@alessandro-bottamedi what do you think, should that be possible?
alessandro-bottamedi commented
The philosophy of the package has always been to remain as simple as possible without including external libraries. I would prefer to create a new chalkConsoleTransport that takes as transportOption chalk, and gives the ability to use rgb colors via chalk.
alessandro-bottamedi commented
Example custom transport using chalk:
import { logger, transportFunctionType } from "react-native-logs";
import chalk from 'chalk';
const customTransport: transportFunctionType = (props) => {
let msg = props.msg;
switch(props.level.text) {
case 'error':
msg = chalk.red(msg);
break;
case 'warn':
msg = chalk.yellow(msg);
break;
default:
// code block
}
console.log(msg)
};
const config = {
transport: customTransport,
};
var log = logger.createLogger(config);
log.error("Red error message");