Skip to content

Commit 5428c16

Browse files
authored
Merge pull request #16 from dhensby/pulls/ai-log-levels
FIX Use appInsights explicit log levels
2 parents d96561c + a362fcb commit 5428c16

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

lib/winston-azure-application-insights.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@ var DEFAULT_IS_SILENT = false;
1212

1313
// Remaping winston level on Application Insights
1414
function getMessageLevel(winstonLevel) {
15-
16-
// TODO: Find a way to get the actual level values from AI's SDK
17-
// They are defined in SDK's "Library/Contracts.ts"
18-
15+
1916
var levels = {
20-
emerg: 4, // AI 'Critical'
21-
alert: 4, // AI 'Critical'
22-
crit: 4, // AI 'Critical'
23-
error: 3, // AI 'Error'
24-
warning: 2, // AI 'Warning'
25-
warn: 2, // AI 'Warning'
26-
notice: 1, // AI 'Informational'
27-
info: 1, // AI 'Informational'
28-
verbose: 0, // AI 'Verbose'
29-
debug: 0, // AI 'Verbose'
30-
silly: 0 // AI 'Verbose'
17+
emerg: appInsights.Contracts.SeverityLevel.Critical,
18+
alert: appInsights.Contracts.SeverityLevel.Critical,
19+
crit: appInsights.Contracts.SeverityLevel.Critical,
20+
error: appInsights.Contracts.SeverityLevel.Error,
21+
warning: appInsights.Contracts.SeverityLevel.Warning,
22+
warn: appInsights.Contracts.SeverityLevel.Warning,
23+
notice: appInsights.Contracts.SeverityLevel.Information,
24+
info: appInsights.Contracts.SeverityLevel.Information,
25+
verbose: appInsights.Contracts.SeverityLevel.Verbose,
26+
debug: appInsights.Contracts.SeverityLevel.Verbose,
27+
silly: appInsights.Contracts.SeverityLevel.Verbose
3128
};
3229

3330
return winstonLevel in levels ? levels[winstonLevel] : levels.info;

0 commit comments

Comments
 (0)