log

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Index = &ctx.Context{Name: "log", Help: "日志中心",
	Caches: map[string]*ctx.Cache{
		"nlog": &ctx.Cache{Name: "nlog", Value: "0", Help: "日志调用数量"},
		"nout": &ctx.Cache{Name: "nout", Value: "0", Help: "日志输出数量"},
	},
	Configs: map[string]*ctx.Config{
		"logdir": &ctx.Config{Name: "logdir", Value: "var/log", Help: ""},
		"output": &ctx.Config{Name: "output", Value: map[string]interface{}{
			"file": map[string]interface{}{
				"bench": "bench.log",
				"debug": "debug.log",
				"error": "error.log",
				"right": "right.log",
			},
			"font": map[string]interface{}{
				"red":    "\033[31m",
				"green":  "\033[32m",
				"blue":   "\033[34m",
				"yellow": "\033[33m",
			},
			"meta": map[string]interface{}{
				"short": []interface{}{"time", "ship"},
				"long":  []interface{}{"time", "ship"},
			},

			"error":  map[string]interface{}{"value": []interface{}{"error", "red"}},
			"trace":  map[string]interface{}{"value": []interface{}{"error", "red"}},
			"debug":  map[string]interface{}{"value": []interface{}{"debug"}},
			"search": map[string]interface{}{"value": []interface{}{"debug"}},
			"call":   map[string]interface{}{"value": []interface{}{"debug"}},
			"back":   map[string]interface{}{"value": []interface{}{"debug"}},

			"send": map[string]interface{}{"value": []interface{}{"debug"}},
			"recv": map[string]interface{}{"value": []interface{}{"debug"}},

			"bench": map[string]interface{}{"value": []interface{}{"bench"}},
			"begin": map[string]interface{}{"value": []interface{}{"bench", "red"}},
			"start": map[string]interface{}{"value": []interface{}{"bench", "red"}},
			"close": map[string]interface{}{"value": []interface{}{"bench", "red"}},
			"warn":  map[string]interface{}{"value": []interface{}{"bench", "yellow"}},

			"cmd": map[string]interface{}{"value": []interface{}{"bench", "green"},
				"lex": map[string]interface{}{"value": []interface{}{"debug", "green"}},
				"yac": map[string]interface{}{"value": []interface{}{"debug", "green"}},
				"cli": map[string]interface{}{
					"cmd": map[string]interface{}{"value": []interface{}{"debug", "red"}},
				},
				"mdb": map[string]interface{}{
					"note": map[string]interface{}{"value": []interface{}{"debug", "red"}},
				},
				"aaa": map[string]interface{}{
					"auth": map[string]interface{}{"value": []interface{}{"debug", "red"}},
					"hash": map[string]interface{}{"value": []interface{}{"debug", "red"}},
					"rsa":  map[string]interface{}{"value": []interface{}{"debug", "red"}},
				},
			},
			"right": map[string]interface{}{"value": []interface{}{"right"}},
		}, Help: "日志输出配置"},
	},
	Commands: map[string]*ctx.Command{
		"_init": &ctx.Command{Name: "_init", Help: "启动日志", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
			m.Target().Start(m)
			return
		}},
		"log": &ctx.Command{Name: "log level string...", Help: "输出日志, level: 日志类型, string: 日志内容", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
			if log, ok := m.Target().Server.(*LOG); m.Assert(ok) {
				log.Log(m, arg[0], arg[1], arg[2:])
			}
			return
		}},
	},
}

Functions

This section is empty.

Types

type LOG

type LOG struct {
	*ctx.Context
	// contains filtered or unexported fields
}

func (*LOG) Begin

func (log *LOG) Begin(m *ctx.Message, arg ...string) ctx.Server

func (*LOG) Close

func (log *LOG) Close(m *ctx.Message, arg ...string) bool

func (*LOG) Log added in v1.1.1

func (log *LOG) Log(msg *ctx.Message, action string, str string, arg ...interface{})

func (*LOG) Spawn

func (log *LOG) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server

func (*LOG) Start

func (log *LOG) Start(m *ctx.Message, arg ...string) bool

func (*LOG) Value added in v1.1.1

func (log *LOG) Value(msg *ctx.Message, arg ...interface{}) []string

Jump to

Keyboard shortcuts

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