Skip to content

Commit

Permalink
Merge pull request #16 from dhensby/pulls/ai-log-levels
Browse files Browse the repository at this point in the history
FIX Use appInsights explicit log levels
  • Loading branch information
willmorgan authored Sep 20, 2018
2 parents d96561c + a362fcb commit 5428c16
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lib/winston-azure-application-insights.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ var DEFAULT_IS_SILENT = false;

// Remaping winston level on Application Insights
function getMessageLevel(winstonLevel) {

// TODO: Find a way to get the actual level values from AI's SDK
// They are defined in SDK's "Library/Contracts.ts"


var levels = {
emerg: 4, // AI 'Critical'
alert: 4, // AI 'Critical'
crit: 4, // AI 'Critical'
error: 3, // AI 'Error'
warning: 2, // AI 'Warning'
warn: 2, // AI 'Warning'
notice: 1, // AI 'Informational'
info: 1, // AI 'Informational'
verbose: 0, // AI 'Verbose'
debug: 0, // AI 'Verbose'
silly: 0 // AI 'Verbose'
emerg: appInsights.Contracts.SeverityLevel.Critical,
alert: appInsights.Contracts.SeverityLevel.Critical,
crit: appInsights.Contracts.SeverityLevel.Critical,
error: appInsights.Contracts.SeverityLevel.Error,
warning: appInsights.Contracts.SeverityLevel.Warning,
warn: appInsights.Contracts.SeverityLevel.Warning,
notice: appInsights.Contracts.SeverityLevel.Information,
info: appInsights.Contracts.SeverityLevel.Information,
verbose: appInsights.Contracts.SeverityLevel.Verbose,
debug: appInsights.Contracts.SeverityLevel.Verbose,
silly: appInsights.Contracts.SeverityLevel.Verbose
};

return winstonLevel in levels ? levels[winstonLevel] : levels.info;
Expand Down

0 comments on commit 5428c16

Please sign in to comment.