log

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PREFIX = "prefix"
	SUFFIX = "suffix"
)
View Source
const (
	GREEN  = "green"
	YELLOW = "yellow"
	RED    = "red"
)
View Source
const (
	WATCH = "watch"
	BENCH = "bench"
	ERROR = "error"
	TRACE = "trace"
)
View Source
const (
	FILE = "file"
	VIEW = "view"
	SHOW = "show"
)

Variables

View Source
var Index = &ice.Context{Name: "log", Help: "日志模块",
	Configs: map[string]*ice.Config{
		FILE: {Name: FILE, Help: "日志文件", Value: kit.Dict(
			WATCH, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "watch.log"), kit.MDB_LIST, []string{
				ice.LOG_CREATE, ice.LOG_REMOVE,
				ice.LOG_INSERT, ice.LOG_DELETE,
				ice.LOG_SELECT, ice.LOG_MODIFY,
				ice.LOG_EXPORT, ice.LOG_IMPORT,
			}),
			BENCH, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "bench.log"), kit.MDB_LIST, []string{}),
			ERROR, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "error.log"), kit.MDB_LIST, []string{
				ice.LOG_WARN, ice.LOG_ERROR,
			}),
			TRACE, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "trace.log"), kit.MDB_LIST, []string{}),
		)},
		VIEW: {Name: VIEW, Help: "日志格式", Value: kit.Dict(
			GREEN, kit.Dict(PREFIX, "\033[32m", SUFFIX, "\033[0m", kit.MDB_LIST, []string{
				ice.LOG_START, ice.LOG_SERVE,
				ice.LOG_CMDS,
			}),
			YELLOW, kit.Dict(PREFIX, "\033[33m", SUFFIX, "\033[0m", kit.MDB_LIST, []string{
				ice.LOG_AUTH, ice.LOG_COST,
			}),
			RED, kit.Dict(PREFIX, "\033[31m", SUFFIX, "\033[0m", kit.MDB_LIST, []string{
				ice.LOG_WARN, ice.LOG_CLOSE,
			}),
		)},
		SHOW: {Name: SHOW, Help: "日志分流", Value: kit.Dict()},
	},
	Commands: map[string]*ice.Command{
		ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			m.Confm(VIEW, nil, func(key string, value map[string]interface{}) {
				kit.Fetch(value[kit.MDB_LIST], func(index int, k string) {
					m.Conf(SHOW, kit.Keys(k, VIEW), key)
				})
			})
			m.Confm(FILE, nil, func(key string, value map[string]interface{}) {
				kit.Fetch(value[kit.MDB_LIST], func(index int, k string) {
					m.Conf(SHOW, kit.Keys(k, FILE), key)
				})

				if f, p, e := kit.Create(kit.Format(value[kit.MDB_PATH])); m.Assert(e) {
					m.Cap(ice.CTX_STREAM, path.Base(p))
					value[FILE] = bufio.NewWriter(f)
					m.Log_CREATE(kit.MDB_FILE, p)
				}
			})
		}},
		ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			if f, ok := m.Target().Server().(*Frame); ok {

				ice.Log = nil
				close(f.p)
			}
		}},
	},
}

Functions

This section is empty.

Types

type Frame

type Frame struct {
	// contains filtered or unexported fields
}

func (*Frame) Begin

func (f *Frame) Begin(m *ice.Message, arg ...string) ice.Server

func (*Frame) Close

func (f *Frame) Close(m *ice.Message, arg ...string) bool

func (*Frame) Spawn

func (f *Frame) Spawn(m *ice.Message, c *ice.Context, arg ...string) ice.Server

func (*Frame) Start

func (f *Frame) Start(m *ice.Message, arg ...string) bool

type Log

type Log struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL