structrue, logger, main.go

This commit is contained in:
lukas 2023-12-04 14:32:48 +01:00
parent 766b717f83
commit c1125da746
3 changed files with 41 additions and 0 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module git.cmdq.io/meirjann/DataLogue-Backend
go 1.21.4

24
log/logger.go Normal file
View File

@ -0,0 +1,24 @@
package log
import (
"io"
"log"
"os"
"time"
)
type writer struct {
io.Writer
timeFormat string
}
func (w writer) Write(b []byte) (n int, err error) {
return w.Writer.Write(append([]byte(time.Now().Format(w.timeFormat)), b...))
}
func New(msg string) *log.Logger {
if len(msg) > 0 {
return log.New(&writer{os.Stdout, "2006/01/02 15:04:05 "}, "["+msg+"] ", 0)
}
return log.New(&writer{os.Stdout, "2006/01/02 15:04:05 "}, "[info] ", 0)
}

14
main.go Normal file
View File

@ -0,0 +1,14 @@
package main
import (
"git.cmdq.io/meirjann/DataLogue-Backend/log"
)
var logger = log.New("startup")
func main() {
logger.Println("Start")
// set all configs
// init db
// start api
}