Skip to content

Commit

Permalink
Merge pull request #4 from khalil-farashiani/features/add-logger
Browse files Browse the repository at this point in the history
🐛 fix log file path issue
  • Loading branch information
khalil-farashiani authored Apr 5, 2024
2 parents 722ab65 + 9fd7144 commit 18397ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 2 additions & 3 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Golim help:
)

const (
basePath = "/.golim/"
loggerFileName = "/logs/golim.log"
dbPath = "/db/"
loggerFileName = "golim.log"
dbPath = "./db/"
)
22 changes: 22 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"log"
"os"
)

type logger struct {
errLog *log.Logger
}

func initLogger() *logger {
file, err := os.OpenFile(loggerFileName, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
defer file.Close()

return &logger{
errLog: log.New(file, "Error Logger:\t", log.Ldate|log.Ltime|log.Lshortfile),
}
}

0 comments on commit 18397ea

Please sign in to comment.