-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0041a36
commit 5b34b52
Showing
10 changed files
with
121 additions
and
21 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
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
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,47 @@ | ||
import { Logger, LoggerService, LogLevel } from '@nestjs/common'; | ||
|
||
/** | ||
* Wrapper for Nest Logger, since the new ConsoleLogger will only arrive on Nest 8.0 | ||
*/ | ||
export class KeycloakLogger implements LoggerService { | ||
private logger = new Logger('Keycloak'); | ||
|
||
constructor(private readonly logLevels: LogLevel[]) {} | ||
|
||
log(message: any, context?: string) { | ||
this.callWrapped('log', message, context); | ||
} | ||
|
||
error(message: any, trace?: string, context?: string) { | ||
this.callWrapped('error', message, context); | ||
} | ||
|
||
warn(message: any, context?: string) { | ||
this.callWrapped('warn', message, context); | ||
} | ||
|
||
debug?(message: any, context?: string) { | ||
this.callWrapped('debug', message, context); | ||
} | ||
|
||
verbose?(message: any, context?: string) { | ||
this.callWrapped('verbose', message, context); | ||
} | ||
|
||
private isLogLevelEnabled(level: LogLevel): boolean { | ||
return this.logLevels.includes(level); | ||
} | ||
|
||
private callWrapped( | ||
name: 'log' | 'warn' | 'debug' | 'verbose' | 'error', | ||
message: any, | ||
context?: string, | ||
) { | ||
if (!this.isLogLevelEnabled(name)) { | ||
return; | ||
} | ||
const func = this.logger[name]; | ||
|
||
func && func.call(this.logger, message, context); | ||
} | ||
} |
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