forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.ts
More file actions
27 lines (25 loc) · 693 Bytes
/
logger.ts
File metadata and controls
27 lines (25 loc) · 693 Bytes
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
function print(logFn: typeof console.log, style: string, ...args: any[]) {
if (typeof args[0] === 'string') {
const newArgs = [...args];
logFn(
`%cWeb Activity Time Tracker%c${new Date().toLocaleTimeString()}%c ${newArgs.shift()}`,
style,
'background-color: #eaf1fb; padding: 2px 4px; border-radius: 3px',
'',
...newArgs,
);
} else {
logFn('%cWeb Activity Time Tracker', style, ...args);
}
}
export function log(...args: any[]) {
if (__DEV__)
print(
console.log,
'color: white; background-color: #1e8e3e; padding: 2px 4px; border-radius: 3px; font-weight: bold',
...args,
);
}
export const logger = {
log,
};