A console logger that produces beautiful and readable messages.
Messaggio was developed for logging purposes and status reporting in Node.js CLI-Applications.
- Six simple message types (debug, error, fatal, info, warning, success)
- Possibility to ask yes/no questions
- Timers
- Timestamp and date support
- Fully customizable (add new message types or change existing ones)
- Two beautiful message output formats:
line
andbox
- Written in Typescript
You need at least Node.js version 10.15.0 installed on your computer.
Open your command line, go to the root folder of your project which contains the package.json file and insert the following command to install the latest version of Messaggio.
npm install messaggio
import { Messagio } from 'messagio';
const messaggio = new Messagio();
messaggio.debug('Debug Message');
messaggio.error('Error Message');
messaggio.fatal('Fatal Error Message');
messaggio.info('Info Message');
messaggio.success('Success Message');
messaggio.warning('Warning Message');
import { Messagio } from 'messagio';
const messaggio = new Messagio();
messaggio.questionYesNo('Do you really want to delete x?')
.then((answer) => {
// if answer is yes, the return value is true
// if answer is no, the return value is false
})
.catch((error) => {
// handle possible error
});
import { Messagio } from 'messagio';
const messaggio = new Messagio();
const answer = await messaggio.questionYesNo('Do you really want to delete x?');
import { Messagio } from 'messagio';
const messaggio = new Messagio();
messaggio.startTimer('Transformation XYZ', 'transformation-xyz');
messaggio.success('XYZ has been transformed');
messaggio.stopTimer('transformation-xyz');
The function startTimer()
returns the id of the timer so you could also do the following:
import { Messagio } from 'messagio';
const messaggio = new Messagio();
const id = messaggio.startTimer('Transformation XYZ', 'transformation-xyz');
messaggio.success('XYZ has been transformed');
messaggio.stopTimer(id);
You can also omit the id-parameter from the function startTimer()
. In this case Messaggio will automatically assign an id to the timer.
import { Messagio } from 'messagio';
const messaggio = new Messagio();
const id = messaggio.startTimer('Transformation XYZ');
messaggio.success('XYZ has been transformed');
messaggio.stopTimer(id);
Per default Messaggio doesn't add a scope to the messages it produces. However you can easily change that.
import { Messagio } from 'messagio';
const messaggio = new Messagio({
'scope': 'my-app'
});
messaggio.info('Info Message');
Per default Messaggio tries to horizontally align long messages in such a way that they become more readable. You can deactivate this functionality in the following way:
import { Messagio } from 'messagio';
const messaggio = new Messagio({
'alignLongLinesHorizontally': false
});
messaggio.info('A very very very very very very very very very very very very very very very very very very long Info Message');
Per default Messaggio outputs messagges line by line. However, you can also choose to display messages within boxes:
import { Messagio } from 'messagio';
const messaggio = new Messagio({
'messageFormat': 'box'
});
messaggio.info('An Info Message');
TODO
TODO