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

Commit

Permalink
Simplify Logger interface, remove silly, make level optional (#271)
Browse files Browse the repository at this point in the history
* Simplify Logger interface, remove silly, make level optional

* Add changelog line

* Added line to note that there is a specific breaking change for trace
  • Loading branch information
draffensperger authored and mayurkale22 committed Jan 10, 2019
1 parent 3db8bf5 commit 7af93bb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
- Add support for supplying instrumentation configuration via tracing option. Option argument added to instrumentation interface.
- Add ignoreIncomingPaths and ignoreOutgoingUrls support to the http and https tracing instrumentations.

**Contains API breaking changes for trace implementations**

- Modify `Logger` interface: `level` made optional, `silly` removed.

## 0.0.8 - 2018-12-14
**Contains API breaking changes for stats/metrics implementations**

Expand Down
12 changes: 1 addition & 11 deletions packages/opencensus-core/src/common/console-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const logDriver = require('log-driver');
*/
export class ConsoleLogger implements types.Logger {
private logger: typeof logDriver;
static LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly'];
static LEVELS = ['silent', 'error', 'warn', 'info', 'debug'];
level: string;

/**
Expand Down Expand Up @@ -89,16 +89,6 @@ export class ConsoleLogger implements types.Logger {
debug(message: any, ...args: any[]): void {
this.logger.debug(util.format(message, ...args));
}

/**
* Logger silly function.
* @param message menssage silly to log in console
* @param args arguments to log in console
*/
// tslint:disable-next-line:no-any
silly(message: any, ...args: any[]): void {
this.logger.silly(util.format(message, ...args));
}
}

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/opencensus-core/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export type LogFunction = (message: any, ...args: any[]) => void;

/** Defines an logger interface. */
export interface Logger {
level: string;
/** Logger verbosity level. If omitted, `debug` level is assumed. */
level?: string;

error: LogFunction;
warn: LogFunction;
info: LogFunction;
debug: LogFunction;
silly: LogFunction;
}

/** Defines an logger options interface. */
Expand Down
20 changes: 1 addition & 19 deletions packages/opencensus-core/test/test-console-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as logger from '../src/common/console-logger';
import {ConsoleLogger} from '../src/common/console-logger';


const LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly'];
const LEVELS = ['silent', 'error', 'warn', 'info', 'debug'];
let consoleTxt = '';

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

assert.equal(validateString, -1);
});

it('should not log silly', () => {
consoleTxt = '';
consoleLogger.silly('silly test logger');
unhookIntercept();
const validateString = consoleTxt.indexOf('silly');

assert.equal(validateString, -1);
});
});

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

assert.equal(validateString, -1);
});

it('should not log silly', () => {
consoleTxt = '';
consoleLogger.silly('silly test logger');
unhookIntercept();
const validateString = consoleTxt.indexOf('silly');

assert.equal(validateString, -1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class ExporterTestLogger implements Logger {
warn(...args: any[]) {}
// tslint:disable-next-line:no-any
info(...args: any[]) {}
// tslint:disable-next-line:no-any
silly(...args: any[]) {}
}

describe('Stackdriver Stats Exporter', function() {
Expand Down

0 comments on commit 7af93bb

Please sign in to comment.