Skip to content

Commit

Permalink
Use Foal logger in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicPoullain committed Oct 18, 2023
1 parent fcf298f commit 5d797ca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions packages/examples/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ port: 3001
settings:
openapi:
useHooks: true
debug: true
loggerFormat: dev
session:
secret: 'my secret'
staticPath: 'public/'
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/config/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
settings:
debug: true
loggerFormat: dev
logger:
format: dev
7 changes: 5 additions & 2 deletions packages/examples/src/app/controllers/profile.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ApiInfo, ApiServer, Context, dependency, Get, Hook, HttpResponseNotFound, HttpResponseRedirect, Post, render, UserRequired
ApiInfo, ApiServer, Context, dependency, Get, Hook, HttpResponseNotFound, HttpResponseRedirect, Logger, Post, render, UserRequired
} from '@foal/core';
import { Disk, ParseAndValidateFiles } from '@foal/storage';

Expand All @@ -16,6 +16,9 @@ export class ProfileController {
@dependency
disk: Disk;

@dependency
logger: Logger;

@Post('/image')
@Hook(async ctx => { ctx.user = await User.findOneBy({ email: '[email protected]' }); })
@UserRequired()
Expand All @@ -28,7 +31,7 @@ export class ProfileController {
try {
await this.disk.delete(user.profile);
} catch (error: any) {
console.log(error.message);
this.logger.error(error.message, { err: error });
}
}

Expand Down

0 comments on commit 5d797ca

Please sign in to comment.