Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
3455846b
提交
3455846b
authored
10月 15, 2014
作者:
Henry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add log command
上级
c98b0e83
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
64 行增加
和
1 行删除
+64
-1
ipfs.go
cmd/ipfs/ipfs.go
+1
-0
log.go
cmd/ipfs/log.go
+29
-0
log.go
core/commands/log.go
+18
-0
daemon.go
daemon/daemon.go
+2
-0
log.go
util/log.go
+11
-1
util.go
util/util.go
+3
-0
没有找到文件。
cmd/ipfs/ipfs.go
浏览文件 @
3455846b
...
...
@@ -63,6 +63,7 @@ Use "ipfs help <command>" for more information about a command.
cmdIpfsBootstrap
,
cmdIpfsDiag
,
cmdIpfsBlock
,
cmdIpfsLog
,
},
Flag
:
*
flag
.
NewFlagSet
(
"ipfs"
,
flag
.
ExitOnError
),
}
...
...
cmd/ipfs/log.go
0 → 100644
浏览文件 @
3455846b
package
main
import
(
flag
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
commander
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
"github.com/jbenet/go-ipfs/core/commands"
)
var
cmdIpfsLog
=
&
commander
.
Command
{
UsageLine
:
"log"
,
Short
:
"switch logging levels of the daemon"
,
Long
:
`ipfs log - manipulate raw ipfs blocks
ipfs log dht error - log error messages from the dht subsystem
ipfs log merkledag debug - print debug output from the merkledag subsystem
ipfs block is a utility command used to change the logging output of a running daemon.`
,
Run
:
logCmd
,
Flag
:
*
flag
.
NewFlagSet
(
"ipfs-log"
,
flag
.
ExitOnError
),
}
var
logCmd
=
makeCommand
(
command
{
name
:
"log"
,
args
:
2
,
flags
:
nil
,
online
:
true
,
cmdFn
:
commands
.
Log
,
})
core/commands/log.go
0 → 100644
浏览文件 @
3455846b
package
commands
import
(
"io"
"github.com/jbenet/go-ipfs/core"
u
"github.com/jbenet/go-ipfs/util"
)
// Log changes the log level of a subsystem
func
Log
(
n
*
core
.
IpfsNode
,
args
[]
string
,
opts
map
[
string
]
interface
{},
out
io
.
Writer
)
error
{
if
err
:=
u
.
SetLogLevel
(
args
[
0
],
args
[
1
]);
err
!=
nil
{
return
err
}
log
.
Info
(
"Changed Log of '%q' to '%q'"
,
args
[
0
],
args
[
1
])
return
nil
}
daemon/daemon.go
浏览文件 @
3455846b
...
...
@@ -137,6 +137,8 @@ func (dl *DaemonListener) handleConnection(conn manet.Conn) {
err
=
commands
.
BlockGet
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"blockPut"
:
err
=
commands
.
BlockPut
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"log"
:
err
=
commands
.
Log
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
default
:
err
=
fmt
.
Errorf
(
"Invalid Command: '%s'"
,
command
.
Command
)
}
...
...
util/log.go
浏览文件 @
3455846b
...
...
@@ -60,9 +60,19 @@ func SetAllLoggers(lvl logging.Level) {
}
}
// Logger retrieves a particular logger
+ initializes it at a particular level
// Logger retrieves a particular logger
func
Logger
(
name
string
)
*
logging
.
Logger
{
log
:=
logging
.
MustGetLogger
(
name
)
loggers
[
name
]
=
log
return
log
}
// SetLogLevel changes the log level of a specific subsystem
func
SetLogLevel
(
name
,
level
string
)
error
{
_
,
ok
:=
loggers
[
name
]
if
!
ok
{
return
ErrNoSuchLogger
}
return
ErrNotImplemented
}
util/util.go
浏览文件 @
3455846b
...
...
@@ -33,6 +33,9 @@ var ErrSearchIncomplete = errors.New("Error: Search Incomplete.")
// ErrNotFound is returned when a search fails to find anything
var
ErrNotFound
=
ds
.
ErrNotFound
// ErrNoSuchLogger is returned when the util pkg is asked for a non existant logger
var
ErrNoSuchLogger
=
errors
.
New
(
"Error: No such logger"
)
// TildeExpansion expands a filename, which may begin with a tilde.
func
TildeExpansion
(
filename
string
)
(
string
,
error
)
{
return
homedir
.
Expand
(
filename
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论