@firstfleet/fflogger

Log to Loggly, and console in dev

Usage no npm install needed!

<script type="module">
  import firstfleetFflogger from 'https://cdn.skypack.dev/@firstfleet/fflogger';
</script>

README

@firstfleet/fflogger

This is a centralized logger that sends logs to papertrail (or any syslog system, you just need to set your host and port) and to the console when process.env.NODE_ENV is not production This logger is hardcoded for udp, if you want to use a more generic syslog, check out @firstfleet/ffsyslog. Its a modified version of winston-syslog. It adds colors and better formatting, breaking apart multiline messages like stack traces for better readability.

This package requires winston and winston-papertrail. In order to send logs to paper trail, you must set define your options in process.env variables

{
    PAPERTRAIL_HOST: "host", --no default
    PAPERTRAIL_PORT: 8080, --no default
    PAPERTRAIL_PROGRAM: "program-name", --defaults to "default"
    PAPERTRAIL_HOSTNAME: "host machine", -- defaults to os.hostname()
}

If the papertrail config is not setup the papertrail transport will not be created. At minimum you need a host and port.

If you update the JS Docs you can rebuild the documentation by running

npm run build-docs

To publish to npm

  1. Increment the package version
  2. Login by running npm login
  3. Make sure you have been added to the firstfleet org
  4. run npm run send

Example

const logger = require('./ffLogger');

logger.log('info', 'test info log'); //Log with level info
logger.info('test info log'); //Log with level info
logger.debug('debug level log'); //DEBUG level logs only go to console
logger.error('error message', error); //Should really use ffErrorHandler handleError function but this will work