Initial commit

This commit is contained in:
unknown
2026-05-14 00:42:39 +02:00
commit dae8a0a4a1
37 changed files with 1226 additions and 0 deletions

46
payload/core/logger.v Normal file
View File

@@ -0,0 +1,46 @@
module core
import time
enum LogLevel {
info
debug
error
}
pub struct Logger {
mut:
logs string
}
fn log_level_str(level LogLevel) string {
return match level {
.info { 'INFO' }
.debug { 'DEBUG' }
.error { 'ERROR' }
}
}
pub fn (mut l Logger) log(mod string, level LogLevel, msg string) {
timestamp := time.now().format_ss_milli()
full_msg := '[$timestamp] [${log_level_str(level)}] [$mod] $msg'
println(full_msg)
l.logs += full_msg + '\n'
}
pub fn (mut l Logger) info(mod string, msg string) {
l.log(mod, .info, msg)
}
pub fn (mut l Logger) debug(mod string, msg string) {
l.log(mod, .debug, msg)
}
pub fn (mut l Logger) error(mod string, msg string) {
l.log(mod, .error, msg)
}
pub fn (l Logger) get_logs() string {
return l.logs
}