← Go Back
: Console and warnings and alerting for background logging

logging

The logging package provides a few logging functions.

Functions

logger

This curried function provides a console logging function with a given prefix.

import { logger } from '@execonline-inc/logging';

const logger = logger('[EXAMPLE]');
logger('abc', 'def');
// [EXAMPLE] abc def

warner

This curried function provides a console warning function with a given prefix.

import { warner } from '@execonline-inc/logging';

const warner = warner('[EXAMPLE]');
warner('abc', 'def');
// [EXAMPLE] abc def

log

Specific to ExecOnline

A logger with an [EXO] prefix.

import { log } from '@execonline-inc/logging';

log('hello');
// [EXO] hello

logWithTimestamp

A logger with a timestamp prefix.

import { logWithTimestamp } from '@execonline-inc/logging';

logWithTimestamp('hello');
// [2022-05-23T16:34:13.462-04:00] hello

warn

Specific to ExecOnline

A warner with an [EXO] prefix.

import { warn } from '@execonline-inc/logging';

warn('hello');
// [EXO] hello

warnAndNotify

Specific to ExecOnline

This function accepts an error name, an error message, and a context object. It sends the message to the console using warn, and also uses the provided information to post a notification to the third-party Honeybadger exception monitoring service.

import { warnAndNotify as warnAndNotifyImpl } from '@execonline-inc/logging';

export const warnAndNotify = warnAndNotifyImpl(Honeybadger.notify);

const context = { user_id: 123 };
warnAndNotify('ErrorName', 'Some error message', context);
// [EXO] Some error message