kdts-simple-logger
A very compact logging and debugging package
Installation
$ npm install kdts-simple-logger
Usage
Debugger - standalone
// use only the debugger const debug = kdtsDebug; /** * Debug your code * * In order to see you debug outputs, you need to insert "DEBUG=*" * or at least "DEBUG=your_package_name:*" into to the script part of your package.json file * * i.e.: * "scripts": { * ... * "start:debug": "clear && NODE_ENV=development LOG_LEVEL= DEBUG=* node server.js", * ... * } */ debugdebugdebug
Optional step for the logger and morganLogger
The logger and morganLogger accept and object as argument which provide the path to an existing directory where logfiles can be stored
/** * Making sure the log-directory exists */const fs = const path = ;const logDirectory = path; // ensure the log directory existsfs || fs; const opt = pathToLogDir: logDirectory;
Logger - standalone
// without any argumentconst log1 = // with an argument (of type object as defined above) specifying the path to the directory where the the log can be storedconst log1 = log1;log1;log1;log1;log1;log1; // alternative logging log1;log1;log1;log1;log1;log1;
MorganLogger - standalone
// without any argument: defaults to process.stdout and process.stderrconst log2 = // with an argument (of type object as defined above) specifying the path to the directory where the the log can be storedconst log2 = // Middleware HTTP request logger using morgen under the hoodapp;app;
All at once
// without any argumentconst kdtsSimpleLogger = ; // with an argument (of type object as defined above) specifying the path to the directory where the the log can be storedconst kdtsSimpleLogger = ; const debug = kdtsSimpleLoggerdebug;const log1 = kdtsSimpleLoggerlog;const morganAccessLogger = kdtsSimpleLoggermorganAccessLogger;const morganErrorLogger = kdtsSimpleLoggermorganErrorLogger; // use them now as defined above...
Deprecated
- Defining the path to a log dir is now optional and can be left out
const options = pathToLogDir: logDirectory; const kdtsSimpleLogger = ;
- Misspelled
morgenAccessLogger
-> is now -> morganAccessLogger - Misspelled
morgenErrorLogger
-> is now -> morganErrorLogger