MCPcopy Create free account
hub / github.com/alanagoyal/docbase / createClientLogger

Function createClientLogger

lib/client-logger.ts:20–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20const createClientLogger = () => {
21 const currentLevel = getLogLevel()
22
23 return {
24 debug: (message: string, meta?: any) => {
25 if (shouldLog('debug', currentLevel)) {
26 if (process.env.NODE_ENV !== 'production') {
27 console.log(`[DEBUG] ${message}`, meta || '')
28 }
29 }
30 },
31
32 info: (message: string, meta?: any) => {
33 if (shouldLog('info', currentLevel)) {
34 if (process.env.NODE_ENV !== 'production') {
35 console.info(`[INFO] ${message}`, meta || '')
36 }
37 }
38 },
39
40 warn: (message: string, meta?: any) => {
41 if (shouldLog('warn', currentLevel)) {
42 console.warn(`[WARN] ${message}`, meta || '')
43 }
44 },
45
46 error: (message: string, meta?: any) => {
47 if (shouldLog('error', currentLevel)) {
48 console.error(`[ERROR] ${message}`, meta || '')
49 }
50 }
51 }
52}
53
54export const clientLogger = createClientLogger()
55export type ClientLogger = typeof clientLogger

Callers 1

client-logger.tsFile · 0.85

Calls 2

getLogLevelFunction · 0.70
shouldLogFunction · 0.70

Tested by

no test coverage detected