-
-
Save johan--/e6384d7b4fe04268a08616628ca2a5a9 to your computer and use it in GitHub Desktop.
Logger Service and it's console logger implementation to handle logging strategy in dev and prod environment.
This file contains hidden or 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
import { Injectable } from '@angular/core'; | |
import { environment } from '../../../environments/environment'; | |
export interface ILoggerService { | |
info(value: any, ...rest: any[]): void; | |
log(value: any, ...rest: any[]): void; | |
warn(value: any, ...rest: any[]): void; | |
error(value: any, ...rest: any[]): void; | |
} | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class ConsoleLoggerService implements ILoggerService { | |
info(value: any, ...rest: any[]): void { | |
if (!environment.production) | |
console.info(value, rest); | |
} | |
log(value: any, ...rest: any[]): void { | |
if (!environment.production) | |
console.log(value, rest); | |
} | |
warn(value: any, ...rest: any[]): void { | |
if (!environment.production) | |
console.warn(value, rest); | |
} | |
error(value: any, ...rest: any[]): void { | |
if (!environment.production) | |
console.error(value, rest); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment