mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
vps add read log 添加读取文件时的日志
This commit is contained in:
parent
86cd445b1e
commit
1611b2fbcd
@ -127,16 +127,17 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
|
m.Meta = nil
|
||||||
size := 1024
|
size := 1024
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
if s, e := strconv.Atoi(arg[1]); e == nil {
|
if s, e := strconv.Atoi(arg[1]); e == nil {
|
||||||
size = s
|
size = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size)
|
||||||
f.Read(buf)
|
l, e := f.Read(buf)
|
||||||
m.Echo(string(buf))
|
m.Echo(string(buf[:l]))
|
||||||
|
m.Log("info", nil, "read %d", l)
|
||||||
}},
|
}},
|
||||||
"save": &ctx.Command{Name: "save file string...", Help: "写入文件, string: 写入内容, pos: 写入位置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"save": &ctx.Command{Name: "save file string...", Help: "写入文件, string: 写入内容, pos: 写入位置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
f, e := os.Create(arg[0])
|
f, e := os.Create(arg[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user