@evokegroup/logger-notifier-msteams
Allows a Logger (@evokegroup/logger) to send messages to a Microsoft Teams channel
Class: LoggerNotifierMSTeams
Extends: Logger.Notifier
See @evokegroup/logger
constructor(object)
Parameter | Type | Default | Description |
---|---|---|---|
logger | Logger |
The associated Logger (@evokegroup/logger) |
|
severity | Logger.Severity, number, string |
Logger.Severity.Unknown |
The maximum severity to output |
application | string |
The application name. Used in the card title | |
header | string |
A header message to render to the card first | |
webhook | string |
The channel webhook URL |
Methods
notify()
Sends the queued messages to the channel.
Usage
const Logger = require('@evokegroup/logger');
const LoggerNotifierMSTeams = require('@evokegroup/logger-notifier-msteams');
const logger = new Logger(Logger.Severity.Debug, new LoggerNotifierMSTeams({
severity: Logger.Severity.Error,
application: 'test.com',
header: 'Test',
webhook: 'https://outlook.office.com/webhook/'
}));
logger.info('This is a test');
logger.error('An error occurred');
logger.debug('Debug details');
logger.notify()
.finally(() => {
console.log('OK');
});
// MS Teams only receives the errors due to the notifier's severity being set to Logger.Severity.Error