Skip to content

Instantly share code, notes, and snippets.

@buildmotion
Created April 3, 2018 08:10
Show Gist options
  • Save buildmotion/5121e32e30d6af271dd2563cb7179359 to your computer and use it in GitHub Desktop.
Save buildmotion/5121e32e30d6af271dd2563cb7179359 to your computer and use it in GitHub Desktop.
import { Injectable, Optional } from '@angular/core';
import { loggingServiceConfig } from './logging.service.config';
import { Severity } from './severity.enum';
@Injectable()
export class LoggingService {
applicationName = 'Angularlicio.us';
serviceName = 'LoggingService';
source: string;
severity: Severity;
message: string;
timestamp: Date;
log(source: string, severity: Severity, message: string) {
this.source = `${this.applicationName}.${source}`;
this.severity = severity;
this.message = message;
this.timestamp = new Date();
const msg = `${this.message}`;
console.log(`${this.severity} from ${this.source}: ${msg} (${this.timestamp})`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment