summaryrefslogtreecommitdiff
path: root/frontend/src/logger.ts
blob: 80019fdb8293f15ccc7f99b9eef00eb6db8d55d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export const log = (name: string, ...args: any[]) => {
  console.log(
    `%c Decky %c ${name} %c`,
    'background: #16a085; color: black;',
    'background: #1abc9c; color: black;',
    'background: transparent;',
    ...args,
  );
};

export const debug = (name: string, ...args: any[]) => {
  console.debug(
    `%c Decky %c ${name} %c`,
    'background: #16a085; color: black;',
    'background: #1abc9c; color: black;',
    'color: blue;',
    ...args,
  );
};

export const warn = (name: string, ...args: any[]) => {
  console.warn(
    `%c Decky %c ${name} %c`,
    'background: #16a085; color: black;',
    'background: #ffbb00; color: black;',
    'color: blue;',
    ...args,
  );
};

export const error = (name: string, ...args: any[]) => {
  console.error(
    `%c Decky %c ${name} %c`,
    'background: #16a085; color: black;',
    'background: #FF0000;',
    'background: transparent;',
    ...args,
  );
};

class Logger {
  constructor(private name: string) {
    this.name = name;
  }

  log(...args: any[]) {
    log(this.name, ...args);
  }

  debug(...args: any[]) {
    debug(this.name, ...args);
  }

  warn(...args: any[]) {
    warn(this.name, ...args);
  }

  error(...args: any[]) {
    error(this.name, ...args);
  }
}

export default Logger;