Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
4bbd9b2d
提交
4bbd9b2d
authored
7月 29, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix log tail command
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
8ed08ab0
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
6 行增加
和
57 行删除
+6
-57
log.go
core/commands/log.go
+6
-57
没有找到文件。
core/commands/log.go
浏览文件 @
4bbd9b2d
...
...
@@ -3,12 +3,10 @@ package commands
import
(
"fmt"
"io"
"strings"
cmds
"github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/thirdparty/eventlog"
u
"github.com/ipfs/go-ipfs/util"
tail
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ActiveState/tail"
)
// Golang os.Args overrides * and replaces the character argument with
...
...
@@ -80,61 +78,12 @@ var logTailCmd = &cmds.Command{
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
path
:=
fmt
.
Sprintf
(
"%s/logs/events.log"
,
req
.
InvocContext
()
.
ConfigRoot
)
outChan
:=
make
(
chan
interface
{})
r
,
w
:=
io
.
Pipe
()
eventlog
.
WriterGroup
.
AddWriter
(
w
)
go
func
()
{
defer
close
(
outChan
)
t
,
err
:=
tail
.
TailFile
(
path
,
tail
.
Config
{
Location
:
&
tail
.
SeekInfo
{
0
,
2
},
Follow
:
true
,
MustExist
:
true
,
Logger
:
tail
.
DiscardingLogger
,
})
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
return
}
defer
t
.
Stop
()
done
:=
req
.
Context
()
.
Done
()
for
line
:=
range
t
.
Lines
{
// return when context closes
select
{
case
<-
done
:
return
default
:
}
if
line
.
Err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
return
}
// TODO: unpack the line text into a struct and output that
outChan
<-
&
MessageOutput
{
line
.
Text
}
}
<-
req
.
Context
()
.
Done
()
w
.
Close
()
}()
res
.
SetOutput
((
<-
chan
interface
{})(
outChan
))
},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
outChan
,
ok
:=
res
.
Output
()
.
(
<-
chan
interface
{})
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
func
(
v
interface
{})
(
io
.
Reader
,
error
)
{
output
:=
v
.
(
*
MessageOutput
)
return
strings
.
NewReader
(
output
.
Message
+
"
\n
"
),
nil
},
},
nil
},
res
.
SetOutput
(
r
)
},
Type
:
MessageOutput
{},
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论