logging shit

This commit is contained in:
DniproNoise
2026-04-27 21:28:10 +02:00
parent 5e837ba858
commit ac2b8e0adc
4 changed files with 55 additions and 0 deletions

3
nzx_tmpmail/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module git.uwushka.cc/nzx056/nzx056/nzx_tmpmail
go 1.25.4

View File

@@ -0,0 +1,47 @@
package loggingshit
import (
"io"
"log"
"os"
)
var l log.Logger
/*
1: default
2: error
3: critical error
*/
func Log(shit string, lvl int, typeshi ...any) {
switch lvl {
default:
l.Printf(shit, typeshi...)
case 2:
l.Printf("[err] "+shit, typeshi...)
case 3:
l.Panic(shit)
}
}
func init() {
var fl *os.File
_, err := os.Stat("logs")
if err != nil {
fl, err = os.Create("logs")
if err != nil {
panic("couldn't create log file")
}
} else {
fl, err = os.OpenFile("logs", os.O_APPEND, os.ModeAppend)
if err != nil {
panic("couldn't open log file, even tho it exists")
}
}
mw := io.MultiWriter(os.Stdout, fl)
l = *log.New(mw, "[nzx_tmpmail] ", log.LUTC|log.Ldate|log.Ltime)
}

0
nzx_tmpmail/logs Normal file
View File

5
nzx_tmpmail/main.go Normal file
View File

@@ -0,0 +1,5 @@
package main
func main() {
}