Aller au contenu principal

Logger

Le package NPM propose un système de Logger simple à utiliser.

info

Pour utiliser le Logger, vous devez d'abord configurer le Core.

Publier des logs avec le Core​

Avec le Core, vous pouvez configurer facilement plusieurs loggers pour chaque partie de votre Application et publier toutes les informations essentielles vers le Dashboard.

const logger = new Logger({
shouldDisableRemoteLogging: false, // Can be set to true on local development env
});

// By calling this method, you will automatically send a log in the console and publish it to the Abyss Monitor Dashboard
logger.log('This is my first log');
logger.error('This is my first error log');
logger.warn('This is my first warn log');
logger.info('This is my first info log');

// Debug is similar to log but it's automatically save the stack trace
logger.debug('This is my first debug log');

// Advanced log
logger.error(error, {
context: "Mon Context",
scenario: "My Scenario",
// getRequestContext is an easy to use tool to get the current RequestId of your API
// Please check the Express Middleware setup before using it
requestId: getRequestContext().requestId,
});
info

Le Logger accepte plusieurs options. Consultez le package pour la liste complète.