Commit 7244eaa8 authored by jojohoch's avatar jojohoch
Browse files

[player] Set log level to 1 and rename enum LogLevel

parent f1470c89
import { TestBed } from '@angular/core/testing';
import { LogLevels, LogService } from './log.service';
import { LogLevel, LogService } from './log.service';
describe('LoggerService', () => {
let service: LogService;
......@@ -47,24 +47,24 @@ describe('LoggerService', () => {
it('should set LogService.level to "LOG"', () => {
LogService.level = 0;
expect(LogService.level).toEqual(LogLevels.LOG);
expect(LogService.level).toEqual(LogLevel.LOG);
});
it('should set LogService.level to "INFO"', () => {
LogService.level = 1;
expect(LogService.level).toEqual(LogLevels.INFO);
expect(LogService.level).toEqual(LogLevel.INFO);
});
it('should set LogService.level to "WARN"', () => {
LogService.level = 2;
expect(LogService.level).toEqual(LogLevels.WARN);
expect(LogService.level).toEqual(LogLevel.WARN);
});
it('should set LogService.level to "ERROR"', () => {
LogService.level = 3;
expect(LogService.level).toEqual(LogLevels.ERROR);
expect(LogService.level).toEqual(LogLevel.ERROR);
});
it('should set LogService.level to "NONE"', () => {
LogService.level = 4;
expect(LogService.level).toEqual(LogLevels.NONE);
expect(LogService.level).toEqual(LogLevel.NONE);
});
});
import { Injectable } from '@angular/core';
export enum LogLevels { LOG = 0, INFO = 1, WARN = 2, ERROR = 3, NONE = 4}
export enum LogLevel { LOG = 0, INFO = 1, WARN = 2, ERROR = 3, NONE = 4}
@Injectable({
providedIn: 'root'
})
export class LogService {
static level: LogLevels = 0;
static level: LogLevel = 1;
static error(...args: any[]): void {
if (LogService.level >= LogLevels.ERROR) {
if (LogService.level >= LogLevel.ERROR) {
window.console.error.apply( console, args );
}
}
static warn(...args: any[]): void {
if (LogService.level >= LogLevels.WARN) {
if (LogService.level >= LogLevel.WARN) {
window.console.warn.apply( console, args );
}
}
static info(...args: any[]): void {
if (LogService.level >= LogLevels.INFO) {
if (LogService.level >= LogLevel.INFO) {
window.console.info.apply( console, args );
}
}
static log(...args: any[]): void {
if (LogService.level >= LogLevels.LOG) {
if (LogService.level >= LogLevel.LOG) {
window.console.info.apply( console, args );
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment