Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 7af93bb

Browse files
draffenspergermayurkale22
authored andcommitted
Simplify Logger interface, remove silly, make level optional (#271)
* Simplify Logger interface, remove silly, make level optional * Add changelog line * Added line to note that there is a specific breaking change for trace
1 parent 3db8bf5 commit 7af93bb

5 files changed

Lines changed: 9 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
99
- Add support for supplying instrumentation configuration via tracing option. Option argument added to instrumentation interface.
1010
- Add ignoreIncomingPaths and ignoreOutgoingUrls support to the http and https tracing instrumentations.
1111

12+
**Contains API breaking changes for trace implementations**
13+
14+
- Modify `Logger` interface: `level` made optional, `silly` removed.
15+
1216
## 0.0.8 - 2018-12-14
1317
**Contains API breaking changes for stats/metrics implementations**
1418

packages/opencensus-core/src/common/console-logger.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const logDriver = require('log-driver');
2424
*/
2525
export class ConsoleLogger implements types.Logger {
2626
private logger: typeof logDriver;
27-
static LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly'];
27+
static LEVELS = ['silent', 'error', 'warn', 'info', 'debug'];
2828
level: string;
2929

3030
/**
@@ -89,16 +89,6 @@ export class ConsoleLogger implements types.Logger {
8989
debug(message: any, ...args: any[]): void {
9090
this.logger.debug(util.format(message, ...args));
9191
}
92-
93-
/**
94-
* Logger silly function.
95-
* @param message menssage silly to log in console
96-
* @param args arguments to log in console
97-
*/
98-
// tslint:disable-next-line:no-any
99-
silly(message: any, ...args: any[]): void {
100-
this.logger.silly(util.format(message, ...args));
101-
}
10292
}
10393

10494
/**

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ export type LogFunction = (message: any, ...args: any[]) => void;
1919

2020
/** Defines an logger interface. */
2121
export interface Logger {
22-
level: string;
22+
/** Logger verbosity level. If omitted, `debug` level is assumed. */
23+
level?: string;
24+
2325
error: LogFunction;
2426
warn: LogFunction;
2527
info: LogFunction;
2628
debug: LogFunction;
27-
silly: LogFunction;
2829
}
2930

3031
/** Defines an logger options interface. */

packages/opencensus-core/test/test-console-logger.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as logger from '../src/common/console-logger';
1919
import {ConsoleLogger} from '../src/common/console-logger';
2020

2121

22-
const LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly'];
22+
const LEVELS = ['silent', 'error', 'warn', 'info', 'debug'];
2323
let consoleTxt = '';
2424

2525
// TODO: Review test cases: Maybe testing the info log level is sufficient
@@ -86,15 +86,6 @@ describe('ConsoleLogger', () => {
8686

8787
assert.equal(validateString, -1);
8888
});
89-
90-
it('should not log silly', () => {
91-
consoleTxt = '';
92-
consoleLogger.silly('silly test logger');
93-
unhookIntercept();
94-
const validateString = consoleTxt.indexOf('silly');
95-
96-
assert.equal(validateString, -1);
97-
});
9889
});
9990

10091
/** Should disable logger */
@@ -138,14 +129,5 @@ describe('ConsoleLogger', () => {
138129

139130
assert.equal(validateString, -1);
140131
});
141-
142-
it('should not log silly', () => {
143-
consoleTxt = '';
144-
consoleLogger.silly('silly test logger');
145-
unhookIntercept();
146-
const validateString = consoleTxt.indexOf('silly');
147-
148-
assert.equal(validateString, -1);
149-
});
150132
});
151133
});

packages/opencensus-exporter-stackdriver/test/test-stackdriver-monitoring.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class ExporterTestLogger implements Logger {
4444
warn(...args: any[]) {}
4545
// tslint:disable-next-line:no-any
4646
info(...args: any[]) {}
47-
// tslint:disable-next-line:no-any
48-
silly(...args: any[]) {}
4947
}
5048

5149
describe('Stackdriver Stats Exporter', function() {

0 commit comments

Comments
 (0)