From 3ebc7c789811af4003caa73fe8d3995dae460aa0 Mon Sep 17 00:00:00 2001 From: draffensperger Date: Thu, 10 Jan 2019 09:13:55 -0500 Subject: [PATCH 1/3] Simplify Logger interface, remove silly, make level optional --- .../src/common/console-logger.ts | 12 +---------- packages/opencensus-core/src/common/types.ts | 5 +++-- .../test/test-console-logger.ts | 20 +------------------ .../test/test-stackdriver-monitoring.ts | 2 -- 4 files changed, 5 insertions(+), 34 deletions(-) diff --git a/packages/opencensus-core/src/common/console-logger.ts b/packages/opencensus-core/src/common/console-logger.ts index 0033f664c..ed35f961d 100644 --- a/packages/opencensus-core/src/common/console-logger.ts +++ b/packages/opencensus-core/src/common/console-logger.ts @@ -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; /** @@ -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)); - } } /** diff --git a/packages/opencensus-core/src/common/types.ts b/packages/opencensus-core/src/common/types.ts index 71005cb05..152b9053c 100644 --- a/packages/opencensus-core/src/common/types.ts +++ b/packages/opencensus-core/src/common/types.ts @@ -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. */ diff --git a/packages/opencensus-core/test/test-console-logger.ts b/packages/opencensus-core/test/test-console-logger.ts index 32d1960a0..f274a2c78 100644 --- a/packages/opencensus-core/test/test-console-logger.ts +++ b/packages/opencensus-core/test/test-console-logger.ts @@ -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 @@ -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 */ @@ -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); - }); }); }); diff --git a/packages/opencensus-exporter-stackdriver/test/test-stackdriver-monitoring.ts b/packages/opencensus-exporter-stackdriver/test/test-stackdriver-monitoring.ts index 2cbdf6a27..82b8a2630 100644 --- a/packages/opencensus-exporter-stackdriver/test/test-stackdriver-monitoring.ts +++ b/packages/opencensus-exporter-stackdriver/test/test-stackdriver-monitoring.ts @@ -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() { From 5fa730de47610aefd9b2e26490d06b1231de8097 Mon Sep 17 00:00:00 2001 From: draffensperger Date: Thu, 10 Jan 2019 15:43:55 -0500 Subject: [PATCH 2/3] Add changelog line --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5d6c756..0f6dafae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Add Gauges (`DoubleGauge`, `LongGauge`, `DerivedDoubleGauge`, `DerivedLongGauge`) APIs. - 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. +- Modify `Logger` interface: `level` made optional, `silly` removed. ## 0.0.8 - 2018-12-14 **Contains API breaking changes for stats/metrics implementations** From 991e4560ab0933274dbe8e2fe581645241fa90d3 Mon Sep 17 00:00:00 2001 From: draffensperger Date: Thu, 10 Jan 2019 15:48:40 -0500 Subject: [PATCH 3/3] Added line to note that there is a specific breaking change for trace --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f6dafae1..399d47161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. - Add Gauges (`DoubleGauge`, `LongGauge`, `DerivedDoubleGauge`, `DerivedLongGauge`) APIs. - 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