Skip to content

Commit

Permalink
chore(extension-logging): rename @log to @logInvocation
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Dec 6, 2019
1 parent 9782097 commit f7ded73
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions extensions/logging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}`;
}
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@loopback/testlab';
import {format, transports} from 'winston';
import {
log,
logInvocation,
LoggingComponent,
WinstonFormat,
WinstonLogRecord,
Expand All @@ -29,7 +29,7 @@ describe('Logging interceptor', () => {

class MyController {
@get('/greet/{name}')
@log()
@logInvocation()
greet(@param.path.string('name') name: string) {
return `Hello, ${name}`;
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/logging/src/decorators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f7ded73

Please sign in to comment.