From 8158c9bbc360092822f5cb0400644ef37f01b73c Mon Sep 17 00:00:00 2001 From: crusader Date: Sun, 25 Mar 2018 19:35:34 +0900 Subject: [PATCH] ing --- src/commons/logger/core/config.ts | 6 -- src/commons/logger/core/index.ts | 3 - src/commons/logger/core/token.ts | 4 - src/commons/logger/core/type.ts | 26 ------ src/commons/logger/logger.module.ts | 39 -------- src/commons/logger/service/logger.service.ts | 93 -------------------- src/commons/logger/store/logger.action.ts | 20 ----- 7 files changed, 191 deletions(-) delete mode 100644 src/commons/logger/core/config.ts delete mode 100644 src/commons/logger/core/index.ts delete mode 100644 src/commons/logger/core/token.ts delete mode 100644 src/commons/logger/core/type.ts delete mode 100644 src/commons/logger/logger.module.ts delete mode 100644 src/commons/logger/service/logger.service.ts delete mode 100644 src/commons/logger/store/logger.action.ts diff --git a/src/commons/logger/core/config.ts b/src/commons/logger/core/config.ts deleted file mode 100644 index 51264af..0000000 --- a/src/commons/logger/core/config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { LoggerLevel } from './type'; - -export class LoggerConfig { - level: LoggerLevel; - serverLogLevel: LoggerLevel; -} diff --git a/src/commons/logger/core/index.ts b/src/commons/logger/core/index.ts deleted file mode 100644 index 40a47eb..0000000 --- a/src/commons/logger/core/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './config'; -export * from './token'; -export * from './type'; diff --git a/src/commons/logger/core/token.ts b/src/commons/logger/core/token.ts deleted file mode 100644 index 6d8f313..0000000 --- a/src/commons/logger/core/token.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Inject, Injectable, InjectionToken } from '@angular/core'; -import { LoggerLevel } from './type'; - -export const LOGGER_LEVEL = new InjectionToken('LoggerLevel'); diff --git a/src/commons/logger/core/type.ts b/src/commons/logger/core/type.ts deleted file mode 100644 index 72d4473..0000000 --- a/src/commons/logger/core/type.ts +++ /dev/null @@ -1,26 +0,0 @@ -export enum LoggerLevel { - TRACE = 0, - DEBUG, - INFO, - LOG, - WARN, - ERROR, - OFF, -} - -export const LoggerLevelName = [ - 'TRACE', - 'DEBUG', - 'INFO', - 'LOG', - 'WARN', - 'ERROR', - 'OFF' -]; - -export interface ServerLoggingParameter { - level: string; - message: string; - addtional?: string; - timestamp: Date; -} diff --git a/src/commons/logger/logger.module.ts b/src/commons/logger/logger.module.ts deleted file mode 100644 index 4918285..0000000 --- a/src/commons/logger/logger.module.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { - NgModule, - ModuleWithProviders, -} from '@angular/core'; -import { CommonModule } from '@angular/common'; - - - - - - - -@NgModule({ -}) -export class LoggerRootModule { } - -@NgModule({ -}) -export class LoggerFeatureModule { } - -@NgModule({ -}) -export class LoggerModule { - static forRoot(reducers: any): ModuleWithProviders { - return { - ngModule: LoggerRootModule, - providers: [ - ], - }; - } - - static forFeature(featureName: string, reducers?: any): ModuleWithProviders { - return { - ngModule: LoggerFeatureModule, - providers: [ - ], - }; - } -} diff --git a/src/commons/logger/service/logger.service.ts b/src/commons/logger/service/logger.service.ts deleted file mode 100644 index 1081ea8..0000000 --- a/src/commons/logger/service/logger.service.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { - LoggerConfig, - LoggerLevel, -} from '../core'; - - -export abstract class LoggerService { - - public constructor( - private readonly config: LoggerConfig - ) { - - } - - public trace(message, ...additional: any[]): void { - this._log(LoggerLevel.TRACE, message, additional); - } - - public debug(message, ...additional: any[]): void { - this._log(LoggerLevel.DEBUG, message, additional); - } - - public info(message, ...additional: any[]): void { - this._log(LoggerLevel.INFO, message, additional); - } - - public log(message, ...additional: any[]): void { - this._log(LoggerLevel.LOG, message, additional); - } - - public warn(message, ...additional: any[]): void { - this._log(LoggerLevel.WARN, message, additional); - } - - public error(message, ...additional: any[]): void { - this._log(LoggerLevel.ERROR, message, additional); - } - - private _timestamp(): string { - return new Date().toISOString(); - } - - private _log(level: LoggerLevel, logOnServer: boolean, message, additional: any[] = []): void { - if (!message) { - return; - } - - // Allow logging on server even if client log level is off - // if (logOnServer) { - // this._logOnServer(level, message, additional); - // } - - // if no message or the log level is less than the environ - if (level < this.config.level) { - return; - } - - try { - message = typeof message === 'string' ? message - : JSON.stringify(message, null, 2); - } catch (e) { - additional = [message, ...additional]; - message = 'The provided "message" value could not be parsed with JSON.stringify().'; - } - - // Coloring doesn't work in IE - // if (this._isIE) { - // return this._logIE(level, message, additional); - // } - - // const color = this._getColor(level); - - // console.log(`%c${this._timestamp()} [${Levels[level]}]`, `color:${color}`, message, ...additional); - } - - private _getColor(level: LoggerLevel): 'blue' | 'teal' | 'gray' | 'red' | undefined { - switch (level) { - case LoggerLevel.TRACE: - return 'blue'; - case LoggerLevel.DEBUG: - return 'teal'; - case LoggerLevel.INFO: - case LoggerLevel.LOG: - return 'gray'; - case LoggerLevel.WARN: - case LoggerLevel.ERROR: - return 'red'; - case LoggerLevel.OFF: - default: - return; - } - } -} diff --git a/src/commons/logger/store/logger.action.ts b/src/commons/logger/store/logger.action.ts deleted file mode 100644 index 15b419d..0000000 --- a/src/commons/logger/store/logger.action.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { - LoggerLevel, - ServerLoggingParameter, -} from '../core'; - -export enum ActionType { - ServerLogging = '[@@LOGGER] ServerLogging', -} - -export class ServerLogging implements Action { - readonly type = ActionType.ServerLogging; - - constructor(public payload: ServerLoggingParameter) {} -} - -export type Actions = - | ServerLogging -;