-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogging.lib.user.js
More file actions
22 lines (20 loc) · 1.35 KB
/
Logging.lib.user.js
File metadata and controls
22 lines (20 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const Logger = (() => {
const styles = {
manager: 'background:#1976d2;color:#fff;padding:2px 8px;border-radius:10px;font-weight:bold;font-size:10px',
extension: 'background:#388e3c;color:#fff;padding:2px 8px;border-radius:10px;font-weight:bold;font-size:10px',
bridge: 'background:#f57c00;color:#fff;padding:2px 8px;border-radius:10px;font-weight:bold;font-size:10px',
error: 'background:#d32f2f;color:#fff;padding:2px 8px;border-radius:10px;font-weight:bold;font-size:10px',
success: 'background:#2e7d32;color:#fff;padding:2px 8px;border-radius:10px;font-weight:bold;font-size:10px',
warning: 'background:#ed6c02;color:#fff;padding:2px 8px;border-radius:10px;font-weight:bold;font-size:10px'
};
const log = (badge, msg, data) => {
const style = styles[badge.toLowerCase()] || styles.manager;
data ? console.log(`%c${badge.toUpperCase()}%c ${msg}`, style, '', data) : console.log(`%c${badge.toUpperCase()}%c ${msg}`, style, '');
};
return {
info: (badge, msg, data) => log(badge, msg, data),
error: (badge, msg, data) => log('error', `${badge.toUpperCase()} - ${msg}`, data),
success: (badge, msg, data) => log('success', `${badge.toUpperCase()} - ${msg}`, data),
warn: (badge, msg, data) => log('warning', `${badge.toUpperCase()} - ${msg}`, data)
};
})();