Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
m1k1o
GitHub Repository: m1k1o/neko
Path: blob/master/client/src/plugins/log.ts
1301 views
1
import { PluginObject } from 'vue'
2
3
interface Logger {
4
error(error: Error): void
5
warn(...log: any[]): void
6
info(...log: any[]): void
7
debug(...log: any[]): void
8
}
9
10
declare global {
11
const $log: Logger
12
13
interface Window {
14
$log: Logger
15
}
16
}
17
18
declare module 'vue/types/vue' {
19
interface Vue {
20
$log: Logger
21
}
22
}
23
24
const plugin: PluginObject<undefined> = {
25
install(Vue) {
26
window.$log = {
27
error: (error: Error) => console.error('[%cNEKO%c] %cERR', 'color: #498ad8;', '', 'color: #d84949;', error),
28
warn: (...log: any[]) => console.warn('[%cNEKO%c] %cWRN', 'color: #498ad8;', '', 'color: #eae364;', ...log),
29
info: (...log: any[]) => console.info('[%cNEKO%c] %cINF', 'color: #498ad8;', '', 'color: #4ac94c;', ...log),
30
debug: (...log: any[]) => console.log('[%cNEKO%c] %cDBG', 'color: #498ad8;', '', 'color: #eae364;', ...log),
31
}
32
33
Vue.prototype.$log = window.$log
34
},
35
}
36
37
export default plugin
38
39