-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (28 loc) · 992 Bytes
/
index.js
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
const getLoggerParams = (params) => {
if (Array.isArray(params) && params.length) {
if (params[0] && typeof params[0] === 'string') {
const title = params[0]
if (title && params[1] && params[1].action) {
const action = params[1].action
const type = action.type || 'Undefined'
const error = params[1].error
return { title, type, action, error }
}
}
}
return { title: false, type: false, action: false, error: false }
}
export default (...params) => {
const logger = console
const { title, type, action, error } = getLoggerParams(params)
if (title && type && action) {
logger.group(`%c ${title}%c ${type} ✨✨✨`, 'color: gray; font-weight: lighter;', 'font-weight: bold;')
logger.log('%c action ', 'color: #03A9F4; font-weight: bold;', action)
if (error) {
logger.log('%c error ', 'color: #F20404; font-weight: bold;', error)
}
logger.groupEnd()
} else {
logger.log(params)
}
}