1.0.2 • Published 11 months ago

@jacopofilonzi/konsole v1.0.2

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
gitlab
Last release
11 months ago

Konsole

Read the license agreement beafore doing anything with the code (LICENSE.md)

git@jacopofilonzi <> git@konsole

Konsole is a NodeJS library that gives usefull tools for console logging in your application such of log files and multiple log levels.

Declaration

const konsole = new Konsole({
    LogTimestamp: true,
    TimestampFormat: "%Y%/%M%/%d% %h%:%m%:%s%",
    LogFileOutput:  __dirname + "/LOG"
});
  • LogTimestamp: determ whether you want to log the timestamp inside the console or not.

  • TimestampFormat: hose the timestamp format you like the most, default is [YYYY/MM/DD - hh:mm:ss] using the following structure:

     - Hour formats:
        - %h% - Hours (00-23)
        - %H% - Hours (00-12)
        - %p% - AM/PM
        - %m% - Minutes
        - %s% - Seconds
     - Date formats
        - %d% - Day
        - %M% - Month
        - %Y% - Year
  • LogFileOutput: if specified the output directory, the package will create a folder structure like LOG/year/month/day.log wich is plain tet containing the exact replica of what has been written inside the console

Usage

you have 4 differents options to use konsole,

konsole.log

/**
 * Print a log message
 * 
 * @param message - the message to write
 */
konsole.log({message: "Hello World!"})

konsole.debug

/**
 * Print a debug message
 * 
 * @param message - the message to write
 */
konsole.debug({message: "Hello World!"})

konsole.warning

/**
 * Print a warning message
 * 
 * @param message - the message to write
 */
konsole.warning({message: "Hello World!"})

konsole.error

/**
 * Print an error message
 * 
 * @param message - the message to write
 * @param quitProcess - wheather or not to quit the process when true
 * @param errorNo - Error number that will be passed to 'process.exit(<n>)', default is 1
 */
konsole.error({message: "Hello World!", quitProcess: true, errorNo: 1})

Future features

  • Debug log levels: the debug logs will have a level specified with a number by you and the konsole class will have 2 params to set, the max level to console log and the max level to file log.

  • Optional Log to File: if the logFileOutput is set you will have the options to avoid writing some logs to the file.

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago