Commit dd9ff9ae authored by “李磊”'s avatar “李磊”
Browse files

Initial commit

parents
package l
import "testing"
func TestVLog(t *testing.T) {
V(0).Debug("v0")
V(1).Debug("v1")
SetConfig(Config{VerboseLevel: 2})
V(2).Debug("v2")
V(2).Debugf("%s:%s", "fv2", "fv2")
V(3).Debugf("%s:%s", "fv3", "fv3")
V(2).Debugj(map[string]int{"verbose": 2})
V(3).Debugj(map[string]int{"verbose": 3})
logMsgWithStack("INFO", "hello")
}
package option
type LogContainS struct {
All StringSlice // grep A | grep B
Any StringSlice // grep -E "A|B"
AllNot StringSlice // grep -v A | grep -v B
AnyNot StringSlice // grep -v "A" or grep -v "B"
Err bool // error always retain
Warn bool // warn always retain
}
const (
LogContainName = "log-contain"
LogContainNameAll = LogContainName + "-" + "all"
LogContainNameAny = LogContainName + "-" + "any"
LogContainNameAllNot = LogContainName + "-" + "all-not"
LogContainNameAnyNot = LogContainName + "-" + "any-not"
LogContainNameErr = LogContainName + "-" + "err"
LogContainNameWarn = LogContainName + "-" + "warn"
)
const (
LogContainDescAll = "log contain all keywords"
LogContainDescAny = "log contain one of keywords"
LogContainDescAnyNot = "log not contain one of keywords"
LogContainDescAllNot = "log not contain both keywords at the same time"
LogContainDescErr = "log always contain error level"
LogContainDescWarn = "log always contain warn level"
)
var LogContain = LogContainS{
All: StringSlice{},
Any: StringSlice{},
AllNot: StringSlice{},
AnyNot: StringSlice{},
Err: true,
Warn: true,
}
var Fadvise bool
func (l LogContainS) Reset() {
}
package option
import (
"fmt"
)
type StringSlice []string
func (ss *StringSlice) String() string {
return fmt.Sprintf("%v", *ss)
}
func (ss *StringSlice) Set(value string) error {
for _, op := range *ss {
if value == op {
return nil
}
}
*ss = append(*ss, value)
return nil
}
func (ss *StringSlice) Enabled() bool {
return ss != nil && len(*ss) != 0
}
func (ss *StringSlice) Reset(ss2 StringSlice) {
if ss2.Enabled() {
*ss = ss2
}
}
func (ss *StringSlice) Contain(msg string) bool {
if !ss.Enabled() {
return false
}
for _, op := range *ss {
if msg == op {
return true
}
}
return false
}
package option
import (
"testing"
)
func TestStringSlice_Init(t *testing.T) {
var ss = StringSlice{}
var ss2 = StringSlice{"123", "456"}
ss.Reset(ss2)
t.Log(ss)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment