Skip to content

Commit a4cb4ba

Browse files
committed
fix: address additional review comments
summary of changes - removed forcedInfo -> startupInfo - change DiagLogLevel range add STARTUP - removed explicit numeric values on Core.LogLevel
1 parent fc00e10 commit a4cb4ba

File tree

8 files changed

+64
-50
lines changed

8 files changed

+64
-50
lines changed

packages/opentelemetry-api/src/api/diag.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ export class DiagAPI implements DiagLogger {
146146
public debug!: DiagLogFunction;
147147
public info!: DiagLogFunction;
148148
public warn!: DiagLogFunction;
149+
public startupInfo!: DiagLogFunction;
149150
public error!: DiagLogFunction;
150151
public critical!: DiagLogFunction;
151152
public terminal!: DiagLogFunction;
152-
153-
public forcedInfo!: DiagLogFunction;
154153
}

packages/opentelemetry-api/src/diag/consoleLogger.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const consoleMap: { n: keyof DiagLogger; c: keyof Console }[] = [
2424
{ n: 'info', c: 'info' },
2525
{ n: 'debug', c: 'debug' },
2626
{ n: 'verbose', c: 'trace' },
27-
{ n: 'forcedInfo', c: 'info' },
27+
{ n: 'startupInfo', c: 'info' },
2828
];
2929

3030
/**
@@ -73,6 +73,13 @@ export class DiagConsoleLogger implements DiagLogger {
7373
/** Log an error scenario that was not expected and caused the requested operation to fail. */
7474
public error!: DiagLogFunction;
7575

76+
/**
77+
* Logs a general informational message that is used for logging component startup and version
78+
* information without causing additional general informational messages when the logging level
79+
* is set to DiagLogLevel.WARN or lower.
80+
*/
81+
public startupInfo!: DiagLogFunction;
82+
7683
/**
7784
* Log a warning scenario to inform the developer of an issues that should be investigated.
7885
* The requested operation may or may not have succeeded or completed.
@@ -102,12 +109,4 @@ export class DiagConsoleLogger implements DiagLogger {
102109
* in a production environment.
103110
*/
104111
public verbose!: DiagLogFunction;
105-
106-
/**
107-
* Log a general informational message that should always be logged regardless of the
108-
* current {@Link DiagLogLevel) and configured filtering level. This type of logging is
109-
* useful for logging component startup and version information without causing additional
110-
* general informational messages when the logging level is set to DiagLogLevel.WARN or lower.
111-
*/
112-
public forcedInfo!: DiagLogFunction;
113112
}

packages/opentelemetry-api/src/diag/logLevel.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,41 @@ import { DiagLogger, DiagLogFunction, createNoopDiagLogger } from './logger';
2424
* compatibility/migration issues for any implementation that assume the numeric ordering.
2525
*/
2626
export enum DiagLogLevel {
27-
/** DIagnostic Logging level setting to disable all logging (except and forced logs) */
28-
NONE = -99,
27+
/** Diagnostic Logging level setting to disable all logging (except and forced logs) */
28+
NONE = 0,
2929

3030
/**
3131
* Identifies a terminal situation that would cause the API to completely fail to initialize,
3232
* if this type of error is logged functionality of the API is not expected to be functional.
3333
*/
34-
TERMINAL = -2,
34+
TERMINAL = 10,
3535

3636
/**
3737
* Identifies a critical error that needs to be addressed, functionality of the component
3838
* that emits this log detail may non-functional.
3939
*/
40-
CRITICAL = -1,
40+
CRITICAL = 20,
4141

4242
/** Identifies an error scenario */
43-
ERROR = 0,
43+
ERROR = 30,
44+
45+
/** Identifies startup and failure (lower) scenarios */
46+
STARTUP = 40,
4447

4548
/** Identifies a warning scenario */
46-
WARN = 1,
49+
WARN = 50,
4750

4851
/** General informational log message */
49-
INFO = 2,
52+
INFO = 60,
5053

5154
/** General debug log message */
52-
DEBUG = 3,
55+
DEBUG = 70,
5356

5457
/**
5558
* Detailed trace level logging should only be used for development, should only be set
5659
* in a development environment.
5760
*/
58-
VERBOSE = 4,
61+
VERBOSE = 80,
5962

6063
/** Used to set the logging level to include all logging */
6164
ALL = 9999,
@@ -79,19 +82,19 @@ const fallbackLoggerFuncMap: { [n: string]: keyof Logger } = {
7982
info: 'info',
8083
debug: 'debug',
8184
verbose: 'debug',
82-
forcedInfo: 'info',
85+
startupInfo: 'info',
8386
};
8487

8588
/** Mapping from DiagLogger function name to logging level. */
86-
const levelMap: { n: keyof DiagLogger; l: DiagLogLevel; f?: boolean }[] = [
89+
const levelMap: { n: keyof DiagLogger; l: DiagLogLevel }[] = [
8790
{ n: 'terminal', l: DiagLogLevel.TERMINAL },
8891
{ n: 'critical', l: DiagLogLevel.CRITICAL },
8992
{ n: 'error', l: DiagLogLevel.ERROR },
9093
{ n: 'warn', l: DiagLogLevel.WARN },
9194
{ n: 'info', l: DiagLogLevel.INFO },
9295
{ n: 'debug', l: DiagLogLevel.DEBUG },
9396
{ n: 'verbose', l: DiagLogLevel.VERBOSE },
94-
{ n: 'forcedInfo', l: DiagLogLevel.INFO, f: true },
97+
{ n: 'startupInfo', l: DiagLogLevel.ERROR },
9598
];
9699

97100
/**
@@ -130,10 +133,9 @@ export function createLogLevelDiagLogger(
130133
function _filterFunc(
131134
theLogger: DiagLogger,
132135
funcName: keyof DiagLogger,
133-
theLevel: DiagLogLevel,
134-
isForced?: boolean
136+
theLevel: DiagLogLevel
135137
): DiagLogFunction {
136-
if (isForced || maxLevel >= theLevel) {
138+
if (maxLevel >= theLevel) {
137139
return function () {
138140
const orgArguments = arguments as unknown;
139141
const theFunc =
@@ -152,7 +154,7 @@ export function createLogLevelDiagLogger(
152154
const newLogger = {} as DiagLogger;
153155
for (let i = 0; i < levelMap.length; i++) {
154156
const name = levelMap[i].n;
155-
newLogger[name] = _filterFunc(logger, name, levelMap[i].l, levelMap[i].f);
157+
newLogger[name] = _filterFunc(logger, name, levelMap[i].l);
156158
}
157159

158160
return newLogger;

packages/opentelemetry-api/src/diag/logger.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export interface DiagLogger {
5353
/** Log an error scenario that was not expected and caused the requested operation to fail. */
5454
error: DiagLogFunction;
5555

56+
/**
57+
* Logs a general informational message that is used for logging component startup and version
58+
* information without causing additional general informational messages when the logging level
59+
* is set to DiagLogLevel.WARN or lower.
60+
*/
61+
startupInfo: DiagLogFunction;
62+
5663
/**
5764
* Log a warning scenario to inform the developer of an issues that should be investigated.
5865
* The requested operation may or may not have succeeded or completed.
@@ -82,15 +89,6 @@ export interface DiagLogger {
8289
* in a production environment.
8390
*/
8491
verbose: DiagLogFunction;
85-
86-
/**
87-
* Log a general informational message that should always be logged regardless of the
88-
* current or configured logging level {@Link DiagLogLevel} except when the level is set
89-
* to {@Link DiagLogLevel.NONE). This type of logging is useful for logging component
90-
* startup and version information without causing additional general informational messages
91-
* when the logging level is set to DiagLogLevel.WARN or lower.
92-
*/
93-
forcedInfo: DiagLogFunction;
9492
}
9593

9694
// DiagLogger implementation
@@ -99,10 +97,10 @@ export const diagLoggerFunctions: Array<keyof DiagLogger> = [
9997
'debug',
10098
'info',
10199
'warn',
100+
'startupInfo',
102101
'error',
103102
'critical',
104103
'terminal',
105-
'forcedInfo',
106104
];
107105

108106
function noopLogFunction() {}

packages/opentelemetry-api/test/diag/consoleLogger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const expectedConsoleMap: { [n: string]: keyof Console } = {
3535
info: 'info',
3636
debug: 'debug',
3737
verbose: 'trace',
38-
forcedInfo: 'info',
38+
startupInfo: 'info',
3939
};
4040

4141
describe('DiagConsoleLogger', () => {

packages/opentelemetry-api/test/diag/logLevel.test.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const expectedIncompleteMap: { [n: string]: keyof Console } = {
4242
info: 'info',
4343
debug: 'debug',
4444
verbose: 'debug',
45-
forcedInfo: 'info',
45+
startupInfo: 'info',
4646
};
4747

4848
describe('LogLevelFilter DiagLogger', () => {
@@ -54,7 +54,7 @@ describe('LogLevelFilter DiagLogger', () => {
5454
info: null,
5555
debug: null,
5656
verbose: null,
57-
forcedInfo: null,
57+
startupInfo: null,
5858
};
5959

6060
let dummyLogger: DiagLogger;
@@ -118,16 +118,31 @@ describe('LogLevelFilter DiagLogger', () => {
118118
{
119119
message: 'CRITICAL',
120120
level: DiagLogLevel.CRITICAL,
121-
ignoreFuncs: ['verbose', 'debug', 'info', 'warn', 'error'],
121+
ignoreFuncs: [
122+
'verbose',
123+
'debug',
124+
'info',
125+
'warn',
126+
'error',
127+
'startupInfo',
128+
],
122129
},
123130
{
124131
message: 'TERMINAL',
125132
level: DiagLogLevel.TERMINAL,
126-
ignoreFuncs: ['verbose', 'debug', 'info', 'warn', 'error', 'critical'],
133+
ignoreFuncs: [
134+
'verbose',
135+
'debug',
136+
'info',
137+
'warn',
138+
'error',
139+
'critical',
140+
'startupInfo',
141+
],
127142
},
128143
{
129144
message: 'between TERMINAL and NONE',
130-
level: -10,
145+
level: 1,
131146
ignoreFuncs: [
132147
'verbose',
133148
'debug',
@@ -136,6 +151,7 @@ describe('LogLevelFilter DiagLogger', () => {
136151
'error',
137152
'critical',
138153
'terminal',
154+
'startupInfo',
139155
],
140156
},
141157
{
@@ -149,7 +165,7 @@ describe('LogLevelFilter DiagLogger', () => {
149165
'error',
150166
'critical',
151167
'terminal',
152-
'forcedInfo',
168+
'startupInfo',
153169
],
154170
},
155171
{
@@ -163,7 +179,7 @@ describe('LogLevelFilter DiagLogger', () => {
163179
'error',
164180
'critical',
165181
'terminal',
166-
'forcedInfo',
182+
'startupInfo',
167183
],
168184
},
169185
];

packages/opentelemetry-api/test/diag/logger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('DiagLogger functions', () => {
3131
info: null,
3232
debug: null,
3333
verbose: null,
34-
forcedInfo: null,
34+
startupInfo: null,
3535
};
3636

3737
let dummyLogger: DiagLogger;

packages/opentelemetry-core/src/common/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { Exception } from '@opentelemetry/api';
2020
* @see {@link DiagLogLevel} from the api
2121
*/
2222
export enum LogLevel {
23-
ERROR = 0,
24-
WARN = 1,
25-
INFO = 2,
26-
DEBUG = 3,
23+
ERROR,
24+
WARN,
25+
INFO,
26+
DEBUG,
2727
}
2828

2929
/**

0 commit comments

Comments
 (0)