-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
14 lines (13 loc) · 828 Bytes
/
Copy pathlogger.js
File metadata and controls
14 lines (13 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var header = ''
export default (log = null, title = null, noEnter) => {
const now = new Date()
const timeFormat =
(String(now.getHours()).length > 1 ? now.getHours() : '0' + now.getHours()) +
':' + (String(now.getMinutes()).length > 1 ? now.getMinutes() : '0' + now.getMinutes()) +
':' + (String(now.getSeconds()).length > 1 ? now.getSeconds() : '0' + now.getSeconds())
const defaultFormat = String.fromCharCode(0x1b) + '[34;1m' + '[%time%] ' + String.fromCharCode(0x1b) + '[37;1m' + '%header% %log%'
if(title !== null) header = title
if(log === null) return
if (noEnter) return process.stdout.write(defaultFormat.replace('%time%', timeFormat).replace('%log%', log))
console.log(defaultFormat.replace('%time%', timeFormat).replace('%log%', log).replace('%header%', header))
}