Fixed the log class and updated tests
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
010dda1cad
commit
478c7ab38f
@ -1,16 +1,16 @@
|
||||
import { Loggable } from "./interfaces";
|
||||
import { Loggable } from './interfaces';
|
||||
|
||||
class Log {
|
||||
class Index {
|
||||
static log(loggable: Loggable): void {
|
||||
switch (loggable.type) {
|
||||
case 'error':
|
||||
this.error(loggable.from, loggable.data)
|
||||
this.error(loggable.from, loggable.data);
|
||||
break;
|
||||
case 'warn':
|
||||
this.warn(loggable.from, loggable.data)
|
||||
this.warn(loggable.from, loggable.data);
|
||||
break;
|
||||
default:
|
||||
this.info(loggable.from, loggable.data)
|
||||
this.info(loggable.from, loggable.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -20,12 +20,12 @@ class Log {
|
||||
}
|
||||
|
||||
static error(...data: any[]): void {
|
||||
console.error(data)
|
||||
console.error(data);
|
||||
}
|
||||
|
||||
static warn(...data: any[]): void {
|
||||
console.warn(data)
|
||||
console.warn(data);
|
||||
}
|
||||
}
|
||||
|
||||
export default Log;
|
||||
export default Index;
|
@ -1,4 +1,4 @@
|
||||
type LogType = 'info' | 'error' | 'warn'
|
||||
export type LogType = 'info' | 'error' | 'warn';
|
||||
|
||||
export interface Loggable {
|
||||
type: LogType;
|
||||
|
@ -1,20 +1,20 @@
|
||||
import Log from '../src/log/Log';
|
||||
import Index from '../src/Log';
|
||||
|
||||
describe('logging into console', function () {
|
||||
it('info', function () {
|
||||
Log.info('I am an info!');
|
||||
Index.info('I am an info!');
|
||||
});
|
||||
|
||||
it('warn', function () {
|
||||
Log.info('I am a warn!');
|
||||
Index.info('I am a warn!');
|
||||
});
|
||||
|
||||
it('error', function () {
|
||||
Log.info('I am an error!');
|
||||
Index.info('I am an error!');
|
||||
});
|
||||
|
||||
it('loggable', function () {
|
||||
Log.log({
|
||||
Index.log({
|
||||
type: 'info',
|
||||
from: 'log.test.ts',
|
||||
data: 'I am loggable called'
|
||||
|
Loading…
Reference in New Issue
Block a user