File

src/lib/kiewit-logging/kiewit-logging.service.ts

Index

Properties
Methods

Constructor

constructor(http: Http)
Parameters :
Name Type Optional Description
http Http

Methods

Debug
Debug(appName: string, method: string, message: string)
Parameters :
Name Type Optional Description
appName string
method string
message string
Returns : void
Error
Error(appName: string, method: string, message: string)
Parameters :
Name Type Optional Description
appName string
method string
message string
Returns : void
Info
Info(appName: string, method: string, message: string)
Parameters :
Name Type Optional Description
appName string
method string
message string
Returns : void
Private Log
Log(appName: string, method: string, message: string, logLevel: LogLevel)
Parameters :
Name Type Optional Description
appName string
method string
message string
logLevel LogLevel
Returns : void
Trace
Trace(appName: string, method: string, message: string)
Parameters :
Name Type Optional Description
appName string
method string
message string
Returns : void
Warn
Warn(appName: string, method: string, message: string)
Parameters :
Name Type Optional Description
appName string
method string
message string
Returns : void

Properties

data
data:
import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment';
import { Http, RequestOptions, Headers } from '@angular/http';
import { Observable } from 'rxjs/Rx';

@Injectable()
export class KiewitLoggingService {

    data = {
        ApplicationName: '',
        Method: '',
        Message: '',
        LogType: LogLevel.Debug
    };
    
    constructor(private http: Http) { }

    Trace(appName: string, method: string, message: string): void {
        this.Log(appName, method, message, LogLevel.Trace);
    }

    Debug(appName: string, method: string, message: string) {
        this.Log(appName, method, message, LogLevel.Debug);
    }

    Warn(appName: string, method: string, message: string) {
        this.Log(appName, method, message, LogLevel.Warn);
    }

    Error(appName: string, method: string, message: string) {
        this.Log(appName, method, message, LogLevel.Error);
    }

    Info(appName: string, method: string, message: string) {
        this.Log(appName, method, message, LogLevel.Info);
    }

    private Log(appName: string, method: string, message: string, logLevel: LogLevel) {
        this.data.Message = message;
        this.data.LogType = logLevel;
        this.data.ApplicationName = appName;
        this.data.Method = method;

        this.http.post(environment.kcsServiceUrl + 'Logging', this.data)
            .catch(err => {
                console.log('KCS Logging - Error when trying to log.');
                return Observable.throw(err); 
            })
            .subscribe();
    }
}

export enum LogLevel {
    Trace = 1,
    Debug = 2,
    Info = 3,
    Warn = 4,
    Error = 5,
    Fatal = 6
}

results matching ""

    No results matching ""