-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
7 changed files
with
88 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { LogCategory, LogSeverity } from "../../utils/enums.util"; | ||
|
||
export interface Logger { | ||
info(message: string, category?: LogCategory): void; | ||
warn(message: any, category?: LogCategory): void; | ||
error(error: any, category?: LogCategory): void; | ||
} | ||
|
||
export interface LogMessage { | ||
readonly message: string; | ||
readonly severity: LogSeverity; | ||
readonly category: LogCategory; | ||
toLine(maxLength: number): string; | ||
} |
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,15 @@ | ||
export enum LogCategory { | ||
serverpod = 'SERVERPOD', | ||
flutter = 'FLUTTER', | ||
dart = 'DART', | ||
utils = 'UTILS', | ||
terraform = 'TERRAFORM', | ||
extension = 'EXTENSION', | ||
} | ||
|
||
|
||
export enum LogSeverity { | ||
info, | ||
warn, | ||
error, | ||
} |
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,24 @@ | ||
import { Logger } from "../base/interfaces/logger.interface"; | ||
import { LogCategory, LogSeverity } from "./enums.util"; | ||
|
||
export class ExtLogger implements Logger { | ||
|
||
|
||
constructor(private category: LogCategory) { | ||
} | ||
|
||
|
||
private logAppender(message: string, severity: LogSeverity) { | ||
return `${severity === LogSeverity.info ? '\x1b[34mINFO\x1b[0m' : severity === LogSeverity.warn ? '\x1b[33mWARNING\x1b[0m' : '\x1b[31mERROR\x1b[0m'} : [ Serverpod.${this.category} ] - ${message}`; | ||
} | ||
|
||
public info(message: string): void { | ||
console.log(this.logAppender(message, LogSeverity.info)); | ||
} | ||
public warn(message: any): void { | ||
console.warn(this.logAppender(message, LogSeverity.warn)); | ||
} | ||
public error(error: any): void { | ||
console.error(this.logAppender(error, LogSeverity.error)); | ||
} | ||
} |
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