-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(all): allow to add extra metadata to logs
The log methods now accept an object instead of multiple parameters to allow for the passing of extra keys. These keys can be anything, from cloud-provider to anything else you want to add. There's also a lot of refactoring and making some new interfaces for cleaner passing of parameters BREAKING CHANGE: log methods now take an object as the second parameter instead of having 3 extra optional parameters fix #215 #228 #297
- Loading branch information
Showing
70 changed files
with
522 additions
and
1,010 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ name: CI | |
on: | ||
pull_request: | ||
branches: | ||
- 'master' | ||
- 'monorepo' | ||
- 'main' | ||
push: | ||
branches: | ||
- '*' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { AppService } from '../../../benchmarks/interceptor/dist/app.service'; | ||
|
||
@Controller() | ||
export class AppController { | ||
constructor(private readonly appService: AppService) {} | ||
|
||
@Get() | ||
sayHello() { | ||
return this.appService.getHello(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { OgmaModule } from '@ogma/nestjs-module'; | ||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
import { LoggerModule } from './logger.module'; | ||
|
||
@Module({ | ||
imports: [LoggerModule, OgmaModule.forFeature(AppService)], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}) | ||
export class NestedModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { OgmaLogger, OgmaService } from '@ogma/nestjs-module'; | ||
|
||
@Injectable() | ||
export class AppService { | ||
constructor(@OgmaLogger(AppService) private readonly logger: OgmaService) {} | ||
|
||
getHello() { | ||
this.logger.log('Hello NestedModule'); | ||
return { hello: 'World' }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { OgmaModule } from '@ogma/nestjs-module'; | ||
|
||
@Module({ | ||
imports: [ | ||
OgmaModule.forRoot({ | ||
service: { | ||
application: 'NestedModule', | ||
}, | ||
interceptor: false, | ||
}), | ||
], | ||
}) | ||
export class LoggerModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { Test } from '@nestjs/testing'; | ||
import { createProviderToken, OgmaService } from '@ogma/nestjs-module'; | ||
import { NestedModule } from '../src/nested-module/app.module'; | ||
import { AppService } from '../src/nested-module/app.service'; | ||
import { httpPromise } from './utils'; | ||
|
||
describe('NestedModule', () => { | ||
let app: INestApplication; | ||
let ogmaService: OgmaService; | ||
|
||
beforeAll(async () => { | ||
const modRef = await Test.createTestingModule({ | ||
imports: [NestedModule], | ||
}).compile(); | ||
app = modRef.createNestApplication(); | ||
ogmaService = modRef.get(createProviderToken(AppService.name)); | ||
await app.listen(0); | ||
}); | ||
|
||
afterAll(async () => { | ||
await app.close(); | ||
}); | ||
|
||
describe('call endpoint', () => { | ||
let appUrl: string; | ||
beforeAll(async () => { | ||
appUrl = await app.getUrl(); | ||
}); | ||
it('should instantiate and call /', async () => { | ||
const spy = jest.spyOn(ogmaService, 'log'); | ||
await httpPromise(appUrl); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledWith('Hello NestedModule'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.