Documentation ¶
Index ¶
Constants ¶
View Source
const ( PREFIX = "prefix" SUFFIX = "suffix" )
View Source
const ( GREEN = "green" YELLOW = "yellow" RED = "red" )
View Source
const ( BENCH = "bench" WATCH = "watch" ERROR = "error" TRACE = "trace" )
View Source
const ( FILE = "file" VIEW = "view" SHOW = "show" )
Variables ¶
View Source
var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: ice.Configs{ FILE: {Name: FILE, Help: "日志文件", Value: kit.Dict( BENCH, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "bench.log"), mdb.LIST, []string{}), WATCH, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "watch.log"), mdb.LIST, []string{ mdb.CREATE, mdb.REMOVE, mdb.INSERT, mdb.DELETE, mdb.MODIFY, mdb.SELECT, mdb.EXPORT, mdb.IMPORT, }), ERROR, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "error.log"), mdb.LIST, []string{ ice.LOG_WARN, ice.LOG_ERROR, }), TRACE, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "trace.log"), mdb.LIST, []string{ ice.LOG_DEBUG, }), )}, VIEW: {Name: VIEW, Help: "日志格式", Value: kit.Dict( GREEN, kit.Dict(PREFIX, "\033[32m", SUFFIX, "\033[0m", mdb.LIST, []string{ ice.CTX_START, ice.LOG_CMDS, }), YELLOW, kit.Dict(PREFIX, "\033[33m", SUFFIX, "\033[0m", mdb.LIST, []string{ ice.LOG_AUTH, ice.LOG_COST, }), RED, kit.Dict(PREFIX, "\033[31m", SUFFIX, "\033[0m", mdb.LIST, []string{ ice.CTX_CLOSE, ice.LOG_WARN, }), )}, SHOW: {Name: SHOW, Help: "日志分流", Value: kit.Dict()}, }, Commands: ice.Commands{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Confm(VIEW, nil, func(key string, value ice.Map) { kit.Fetch(value[mdb.LIST], func(index int, k string) { m.Conf(SHOW, kit.Keys(k, VIEW), key) }) }) m.Confm(FILE, nil, func(key string, value ice.Map) { kit.Fetch(value[mdb.LIST], func(index int, k string) { m.Conf(SHOW, kit.Keys(k, FILE), key) }) if f, p, e := logs.CreateFile(kit.Format(value[nfs.PATH])); e == nil { m.Cap(ice.CTX_STREAM, path.Base(p)) value[FILE] = bufio.NewWriter(f) m.Logs(mdb.CREATE, nfs.FILE, p) } }) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {}}, }}
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.