- Add to another project as a submodule using the instructions here if not done so already.
- From the
Node-Loggersubmodule:- In the
configfolder:- Copy/rename
config_template.jsontoconfig.jsonand fill in appropriate settings.
- Copy/rename
- In the
rootfolder:- Run
npm installto install required packages. - Run/edit
test.jsto make sure that all connections are good to go.
- Run
- In the
- Import after all other submodules but before any program code:
var _path = require('path'); // import other submodules first var _logger = require(_path.resolve(__dirname, 'Node-Logger', 'app.js')); // rest of program code goes here
_logger.MethodName.Async(...);to log fire-and-forget events.[await] _logger.MethodName.Sync(...).then(...).catch(...);to log events that must be synchronous.- It can also be wrapped in an anonymous
asyncfunction for certain uses (like inside of another callback, shown here)function myFunction(callback(value) => { // some callback code (async () => { // [await] _logger.MethodName.Sync(...).then(...).catch(...); // more code to be called once logging is done })(); });