Skip to content
Snippets Groups Projects
Commit a17f7899 authored by jojohoch's avatar jojohoch
Browse files

[player] Fix LogService.log method

- Improve tests
- Change log level logic
- change default log level
parent 0922e55d
No related branches found
No related tags found
No related merge requests found
......@@ -15,34 +15,34 @@ describe('LoggerService', () => {
it('should call LogService.log', () => {
spyOn(LogService, 'log')
.withArgs('test');
LogService.log('test');
.withArgs('test', 'test2');
LogService.log('test', 'test2');
expect(LogService.log).toHaveBeenCalled();
expect(LogService.log).toHaveBeenCalledWith('test');
expect(LogService.log).toHaveBeenCalledWith('test', 'test2');
});
it('should call LogService.info', () => {
spyOn(LogService, 'info')
.withArgs('test');
LogService.info('test');
.withArgs('test', 'test2');
LogService.info('test', 'test2');
expect(LogService.info).toHaveBeenCalled();
expect(LogService.info).toHaveBeenCalledWith('test');
expect(LogService.info).toHaveBeenCalledWith('test', 'test2');
});
it('should call LogService.warn', () => {
spyOn(LogService, 'warn')
.withArgs('test');
LogService.warn('test');
.withArgs('test', 'test2');
LogService.warn('test', 'test2');
expect(LogService.warn).toHaveBeenCalled();
expect(LogService.warn).toHaveBeenCalledWith('test');
expect(LogService.warn).toHaveBeenCalledWith('test', 'test2');
});
it('should call LogService.error', () => {
spyOn(LogService, 'error')
.withArgs('test');
LogService.error('test');
.withArgs('test', 'test2');
LogService.error('test', 'test2');
expect(LogService.error).toHaveBeenCalled();
expect(LogService.error).toHaveBeenCalledWith('test');
expect(LogService.error).toHaveBeenCalledWith('test', 'test2');
});
it('should set LogService.level to "LOG"', () => {
......
......@@ -6,33 +6,33 @@ export enum LogLevel { LOG = 0, INFO = 1, WARN = 2, ERROR = 3, NONE = 4}
providedIn: 'root'
})
export class LogService {
static level: LogLevel = 1;
static level: LogLevel = 3;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static error(...args: any[]): void {
if (LogService.level >= LogLevel.ERROR) {
if (LogService.level <= LogLevel.ERROR) {
window.console.error.apply( console, args );
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static warn(...args: any[]): void {
if (LogService.level >= LogLevel.WARN) {
if (LogService.level <= LogLevel.WARN) {
window.console.warn.apply( console, args );
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static info(...args: any[]): void {
if (LogService.level >= LogLevel.INFO) {
if (LogService.level <= LogLevel.INFO) {
window.console.info.apply( console, args );
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static log(...args: any[]): void {
if (LogService.level >= LogLevel.LOG) {
window.console.info.apply( console, args );
if (LogService.level <= LogLevel.LOG) {
window.console.log.apply( console, args );
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment