From 45a8e7fc0088cbde1292118e004af4c38689d90a Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 24 Oct 2019 17:32:44 +0800 Subject: [PATCH] add dir.mime --- src/contexts/cli/version.go | 2 +- src/contexts/log/log.go | 13 ++++++++++--- src/contexts/nfs/nfs.go | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index 71582195..ab8537a0 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -7,5 +7,5 @@ var version = struct { self int }{ []string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"}, - `2019-10-24 09:49:55`, `mac`, 653, + `2019-10-24 16:28:20`, `centos`, 642, } diff --git a/src/contexts/log/log.go b/src/contexts/log/log.go index c0a74ea6..b077c340 100644 --- a/src/contexts/log/log.go +++ b/src/contexts/log/log.go @@ -96,10 +96,14 @@ func (log *LOG) Start(m *ctx.Message, arg ...string) bool { font := m.Conf("output", []string{"font", kit.Select("", value, 1)}) meta := msg.Format(m.Confv("output", []string{"meta", kit.Select("short", value, 2)}).([]interface{})...) - // 输出日志 - fmt.Fprintln(file, fmt.Sprintf("%d %s %s%s %s%s", m.Capi("nout", 1), meta, font, + str := fmt.Sprintf("%d %s %s%s %s%s", m.Capi("nout", 1), meta, font, kit.Format(l["action"]), fmt.Sprintf(kit.Format(l["str"]), l["arg"].([]interface{})...), - kit.Select("", "\033[0m", font != ""))) + kit.Select("", "\033[0m", font != "")) + + // 输出日志 + if fmt.Fprintln(file, str); m.Confs("output", []string{"stdio", value[0]}) { + fmt.Println(str) + } break loop } } @@ -121,6 +125,9 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心", "logdir": &ctx.Config{Name: "logdir", Value: "var/log", Help: "日志目录"}, "output": &ctx.Config{Name: "output", Value: map[string]interface{}{ + "stdio": map[string]interface{}{ + "bench": false, + }, "file": map[string]interface{}{ "debug": "debug.log", "bench": "bench.log", diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 1537a926..ebb87dc8 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -561,6 +561,17 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", "type": "both", "temp": "var/tmp/file", "trash": "var/tmp/trash", + "mime": map[string]interface{}{ + "js": "txt", + "css": "txt", + "html": "txt", + "shy": "txt", + "py": "txt", + "go": "txt", + "h": "txt", + "c": "txt", + "gz": "bin", + }, }, Help: "目录管理"}, "pwd": &ctx.Config{Name: "pwd", Value: []interface{}{ "", "usr/local", "usr", "var", "bin", "etc", "src", "src/plugin", @@ -637,6 +648,8 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", return sed(m, arg[0], args) } + mime := m.Conf("dir", []string{"mime", strings.TrimPrefix(path.Ext(arg[0]), ".")}) + skip, find := false, false m.Confm("pwd", func(index int, value string) bool { p := kit.Select("./", path.Join(value, arg[0])) @@ -649,7 +662,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", dir(m, kit.Pwd(), p, 0, kit.Right(m.Has("dir_deep")), dir_type, rg, fields, m.Conf("time", "format")) - } else if s.Size() > int64(m.Confi("buf", "size")) { + } else if mime != "txt" && (mime == "bin" || s.Size() > int64(m.Confi("buf", "size"))) { m.Append("directory", p) } else {