- Add to another project as a submodule using the instructions here if not done so already.
- From the
Node-Logger
submodule:- In the
config
folder:- Copy/rename
config_template.json
toconfig.json
and fill in appropriate settings.
- Copy/rename
- In the
root
folder:- Run
npm install
to install required packages. - Run/edit
test.js
to 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
async
function 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 })(); });