update log add date utils

master
ehlxr 2017-07-11 17:33:03 +08:00
parent a5e6669573
commit 1c7c9a54c8
3 changed files with 37 additions and 1 deletions

24
date/formater.go Normal file
View File

@ -0,0 +1,24 @@
package date
import (
"fmt"
)
const (
YYYYMMDDHHmmSS = "2006-01-02 15:04:05"
)
func Formater(formater string) string {
r := ""
for _, v := range formater {
s := fmt.Sprintf("%c", v)
switch s {
case "y", "Y":
r += s
case "-", " ":
r += s
}
}
return r
}

11
date/formater_test.go Normal file
View File

@ -0,0 +1,11 @@
package date
import (
"testing"
"github.com/ehlxr/go-utils/log"
)
func TestDateFormater(t *testing.T) {
log.Infof("now tims is %s", Formater("yyyy-MM-dd HH:mm:ss"))
}

View File

@ -16,7 +16,7 @@ type (
var (
mylog *logrus.Logger
fn bool
fn bool //whether show file line
)
func init() {
@ -36,6 +36,7 @@ func init() {
fn = true
}
// whether show file line
func SetFn(val bool) {
fn = val
}