summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/logger/loggers.go')
-rw-r--r--pkg/logger/loggers.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/logger/loggers.go b/pkg/logger/loggers.go
new file mode 100644
index 0000000..0ef51e9
--- /dev/null
+++ b/pkg/logger/loggers.go
@@ -0,0 +1,39 @@
+package logger
+
+import (
+ "io"
+ "log"
+ "os"
+)
+
+var (
+ Debug *log.Logger
+ Info *log.Logger
+ Error *log.Logger
+)
+
+func Init(
+ debugHandle io.Writer,
+ infoHandle io.Writer,
+ errorHandle io.Writer) {
+
+ Debug = log.New(debugHandle,
+ "DEBUG: ",
+ log.Ldate|log.Ltime|log.Lshortfile)
+
+ Info = log.New(infoHandle,
+ "INFO: ",
+ log.Ldate|log.Ltime|log.Lshortfile)
+
+ Error = log.New(errorHandle,
+ "ERROR: ",
+ log.Ldate|log.Ltime|log.Lshortfile)
+}
+
+func CreateLogFile(path string) *os.File {
+ f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
+ if err != nil {
+ log.Println(err)
+ }
+ return f
+}