Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Arnheiter committed Jan 28, 2021
0 parents commit 76a01f2
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/bin/
.idea/
/config/
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module "github.com/z26100/log-go"
89 changes: 89 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package log

import (
"log"
"net/http"
)

type LogLevelType int

const (
TRACE LogLevelType = iota
DEBUG
INFO
WARN
ERROR
FATAL
)

var (
LogLevel = INFO
)

func Println(args ...interface{}) {
Infoln(args)
}
func Printf(format string, args ...interface{}) {
Infof(format, args)
}


func Fatalln (args ...interface{}) {
if LogLevel <= FATAL { log.Fatal(args)}
}
func Fatalf (format string, args ...interface{}) {
if LogLevel <= FATAL { log.Fatal(format, args)}
}


func Errorln (args ...interface{}) {
if LogLevel <= ERROR { log.Println(args)}
}
func Errorf (format string, args ...interface{}) {
if LogLevel <= ERROR { log.Printf(format, args)}
}


func Warnln (args ...interface{}) {
if LogLevel <= WARN { log.Println(args)}
}
func Warnf (format string, args ...interface{}) {
if LogLevel <= WARN { log.Printf(format, args)}
}


func Infoln (args ...interface{}) {
if LogLevel <= INFO { log.Println(args)}
}
func Infof (format string, args ...interface{}) {
if LogLevel <= INFO { log.Printf(format, args)}
}

func Debugln( args ...interface{}) {
if LogLevel <= DEBUG { log.Println(args)}
}
func Debugf(format string, args ...interface{}) {
if LogLevel <= DEBUG { log.Printf(format, args)}
}

func Traceln( args ...interface{}) {
if LogLevel <= TRACE { log.Println(args)}
}
func Tracef(format string, args ...interface{}) {
if LogLevel <= TRACE { log.Printf(format, args)}
}


func Error(args ...interface{}) {
log.Println(args)
}

func Fatal(err error) {
log.Fatal(err)
}
func Handler (handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Debugln("http request", r.Method, r.URL)
handler.ServeHTTP(w, r)
})
}

0 comments on commit 76a01f2

Please sign in to comment.