From f7ded73a6c41991ea8cbf25d63afa2cc8b9e472f Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 6 Dec 2019 09:24:49 -0800 Subject: [PATCH] chore(extension-logging): rename @log to @logInvocation --- extensions/logging/README.md | 8 ++++---- .../accpetance/logging.interceptor.acceptance.ts | 4 ++-- extensions/logging/src/decorators/index.ts | 2 +- .../decorators/{log.decorator.ts => logging.decorator.ts} | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) rename extensions/logging/src/decorators/{log.decorator.ts => logging.decorator.ts} (78%) diff --git a/extensions/logging/README.md b/extensions/logging/README.md index 0e40322066a5..ffb11eca310b 100644 --- a/extensions/logging/README.md +++ b/extensions/logging/README.md @@ -43,7 +43,7 @@ facilities: ```ts import {inject} from '@loopback/context'; -import {Logger, log} from '@loopback/extension-logging'; +import {Logger, logInvocation} from '@loopback/extension-logging'; import {get, param} from '@loopback/rest'; class MyController { @@ -54,7 +54,7 @@ class MyController { // http access is logged by a global interceptor @get('/greet/{name}') // log the `greet` method invocations - @log() + @logInvocation() greet(@param.path.string('name') name: string) { return `Hello, ${name}`; } @@ -85,8 +85,8 @@ namespace below: - FLUENT_SENDER - A fluent sender - WINSTON_LOGGER - A winston logger - WINSTON_TRANSPORT_FLUENT - A fluent transport for winston -- WINSTON_INTERCEPTOR - A local interceptor set by `@log` to log method - invocations +- WINSTON_INTERCEPTOR - A local interceptor set by `@logInvocation` to log + method invocations - WINSTON_HTTP_ACCESS_LOGGER - A global interceptor that logs http access with [Morgan](https://github.com/expressjs/morgan) format diff --git a/extensions/logging/src/__tests__/accpetance/logging.interceptor.acceptance.ts b/extensions/logging/src/__tests__/accpetance/logging.interceptor.acceptance.ts index b8559a540e1c..673cd1dbf4d4 100644 --- a/extensions/logging/src/__tests__/accpetance/logging.interceptor.acceptance.ts +++ b/extensions/logging/src/__tests__/accpetance/logging.interceptor.acceptance.ts @@ -13,7 +13,7 @@ import { } from '@loopback/testlab'; import {format, transports} from 'winston'; import { - log, + logInvocation, LoggingComponent, WinstonFormat, WinstonLogRecord, @@ -29,7 +29,7 @@ describe('Logging interceptor', () => { class MyController { @get('/greet/{name}') - @log() + @logInvocation() greet(@param.path.string('name') name: string) { return `Hello, ${name}`; } diff --git a/extensions/logging/src/decorators/index.ts b/extensions/logging/src/decorators/index.ts index a13b199d64e5..61992178bdf2 100644 --- a/extensions/logging/src/decorators/index.ts +++ b/extensions/logging/src/decorators/index.ts @@ -3,4 +3,4 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -export * from './log.decorator'; +export * from './logging.decorator'; diff --git a/extensions/logging/src/decorators/log.decorator.ts b/extensions/logging/src/decorators/logging.decorator.ts similarity index 78% rename from extensions/logging/src/decorators/log.decorator.ts rename to extensions/logging/src/decorators/logging.decorator.ts index 85d25a5362d1..3d2d0a65b720 100644 --- a/extensions/logging/src/decorators/log.decorator.ts +++ b/extensions/logging/src/decorators/logging.decorator.ts @@ -7,21 +7,21 @@ import {intercept} from '@loopback/context'; import {LoggingBindings} from '../keys'; /** - * @log decorator for method invocations. + * @logInvocation decorator for method invocations. * * @example * ```ts - * import {log} from '@loopback/extension-logging'; + * import {logInvocation} from '@loopback/extension-logging'; * * export class HelloController { - * @log() + * @logInvocation() * hello(name: string) { * return `Hello, ${name}`; * } * } * ``` */ -export function log() { +export function logInvocation() { // A shortcut to `@intercept` that invokes the winston interceptor that logs // method invocations return intercept(LoggingBindings.WINSTON_INVOCATION_LOGGER);