🖼️Reporters
Create your own themes to log the messages
Reporters are basically an object, which has to be an instance of a superclass of the Reporter class, we will cover the different ways to create a reporter and how to use it in our logger.
import { Reporter } from 'loxt'
const myReporter = new Reporter({
info: 'info: $message',
warn: 'warn: $message',
ready: 'ready $message',
start: 'start $message',
success: 'sucess: $message',
// This is error default
error: {
name: '$name',
message: '$message'
},
});
But maybe you must add some extra logic to the reporter, for that you can make a new class that extends the reporter class and add the right getters. We call this class an Extension, as it extends our basic theme reporter and adds new functionality.
import { Reporter } from 'loxt';
export class MyTheme extends Reporter {
get info() {
return `info: $message`;
}
get warn() {
return `warn: $message`;
}
get ready() {
return `ready $message`;
}
get start() {
return `start $message`;
}
get success() {
return `success: $message`;
}
get error() {
return {
name: '$name'
message: '$message'
};
}
}
If you want to add colors you can use the Colors module integrated in this library.
Last updated