-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
54 lines (49 loc) · 1.49 KB
/
Copy pathlog.js
File metadata and controls
54 lines (49 loc) · 1.49 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Helper para generar timestamp en formato [YYYY-MM-DD HH:MM:SS]
*/
function timestamp() {
const iso = new Date().toISOString();
const [date, timeFull] = iso.split('T');
const time = timeFull.slice(0, 8); // HH:MM:SS
return `[${date} ${time}]`;
}
/**
* A utility object for logging messages with different levels of importance.
* Provides methods for logging errors, general messages, successes, and warnings.
* All messages are sent to stdout with timestamps.
*/
const log = {
/**
* Logs an error message to stdout with a red circle emoji and timestamp.
*
* @param {...any} args - The arguments to be logged as an error message.
*/
error(...args) {
console.log(timestamp(), '🔴', ...args);
},
/**
* Logs an info message to stdout with a blue circle emoji and timestamp.
*
* @param {...any} args - The arguments to be logged as part of the info message.
*/
info(...args) {
console.log(timestamp(), '🔵', ...args);
},
/**
* Logs a success message to stdout with a green circle emoji and timestamp.
*
* @param {...any} args - The arguments to be logged as part of the success message.
*/
success(...args) {
console.log(timestamp(), '🟢', ...args);
},
/**
* Logs a warning message to stdout with an orange circle emoji and timestamp.
*
* @param {...any} args - The arguments to be logged as part of the warning message.
*/
warning(...args) {
console.log(timestamp(), '🟠', ...args);
}
}
export default log;