| 59 | } |
| 60 | |
| 61 | function generate_timestamp() { |
| 62 | const UTC8_OFFSET = 0; // Correct UTC+8 offset |
| 63 | const t = new Date((new Date().getTime()) + UTC8_OFFSET * 60 * 60 * 1000); |
| 64 | |
| 65 | const year = t.getFullYear(); |
| 66 | const month = pad_number(t.getMonth() + 1); |
| 67 | const day = pad_number(t.getDate()); |
| 68 | const hours = pad_number(t.getHours()); |
| 69 | const minutes = pad_number(t.getMinutes()); |
| 70 | const seconds = pad_number(t.getSeconds()); |
| 71 | |
| 72 | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| 73 | } |
| 74 | |
| 75 | function formatted_message(timestamp, level, message) { |
| 76 | const formatted = typeof message === 'object' ? JSON.stringify(message, null, 2) : message; |