Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
210b5df7
提交
210b5df7
authored
10月 25, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use my go-logging fork
until
https://github.com/op/go-logging/pull/30
is merged
上级
762faa74
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
91 行增加
和
21 行删除
+91
-21
Godeps.json
Godeps/Godeps.json
+4
-4
.travis.yml
...s/_workspace/src/github.com/jbenet/go-logging/.travis.yml
+0
-0
CONTRIBUTORS
.../_workspace/src/github.com/jbenet/go-logging/CONTRIBUTORS
+0
-0
LICENSE
Godeps/_workspace/src/github.com/jbenet/go-logging/LICENSE
+0
-0
README.md
Godeps/_workspace/src/github.com/jbenet/go-logging/README.md
+0
-1
backend.go
...ps/_workspace/src/github.com/jbenet/go-logging/backend.go
+0
-0
example.go
...pace/src/github.com/jbenet/go-logging/examples/example.go
+1
-1
example.png
...ace/src/github.com/jbenet/go-logging/examples/example.png
+0
-0
format.go
Godeps/_workspace/src/github.com/jbenet/go-logging/format.go
+0
-0
format_test.go
...workspace/src/github.com/jbenet/go-logging/format_test.go
+0
-0
level.go
Godeps/_workspace/src/github.com/jbenet/go-logging/level.go
+0
-0
level_test.go
..._workspace/src/github.com/jbenet/go-logging/level_test.go
+0
-0
log.go
Godeps/_workspace/src/github.com/jbenet/go-logging/log.go
+0
-0
log_test.go
...s/_workspace/src/github.com/jbenet/go-logging/log_test.go
+0
-0
logger.go
Godeps/_workspace/src/github.com/jbenet/go-logging/logger.go
+64
-10
logger_test.go
...workspace/src/github.com/jbenet/go-logging/logger_test.go
+18
-1
memory.go
Godeps/_workspace/src/github.com/jbenet/go-logging/memory.go
+0
-0
memory_test.go
...workspace/src/github.com/jbenet/go-logging/memory_test.go
+2
-2
multi.go
Godeps/_workspace/src/github.com/jbenet/go-logging/multi.go
+0
-0
multi_test.go
..._workspace/src/github.com/jbenet/go-logging/multi_test.go
+0
-0
syslog.go
Godeps/_workspace/src/github.com/jbenet/go-logging/syslog.go
+0
-0
dagmodifier_test.go
unixfs/io/dagmodifier_test.go
+1
-1
log.go
util/log.go
+1
-1
没有找到文件。
Godeps/Godeps.json
浏览文件 @
210b5df7
...
...
@@ -88,6 +88,10 @@
"Rev"
:
"93b717f2ae17838a265e30277275ee99ee7198d6"
},
{
"ImportPath"
:
"github.com/jbenet/go-logging"
,
"Rev"
:
"74bec4b83f6d45d1402c1e9d94c0c29e39f6e0ea"
},
{
"ImportPath"
:
"github.com/jbenet/go-msgio"
,
"Rev"
:
"c9069ab79c95aa0686347b516972c7329c4391f2"
},
...
...
@@ -110,10 +114,6 @@
"Rev"
:
"7d2d8c8a4e078ce3c58736ab521a40b37a504c52"
},
{
"ImportPath"
:
"github.com/op/go-logging"
,
"Rev"
:
"3df864a88c7f005e676db4f026a4fe2f14929be3"
},
{
"ImportPath"
:
"github.com/syndtr/goleveldb/leveldb"
,
"Rev"
:
"99056d50e56252fbe0021d5c893defca5a76baf8"
},
...
...
Godeps/_workspace/src/github.com/
op
/go-logging/.travis.yml
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/.travis.yml
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/CONTRIBUTORS
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/CONTRIBUTORS
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/LICENSE
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/LICENSE
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/README.md
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/README.md
浏览文件 @
210b5df7
...
...
@@ -80,4 +80,3 @@ You can use `go get -u` to update the package.
For docs, see http://godoc.org/github.com/op/go-logging or run:
$ godoc github.com/op/go-logging
Godeps/_workspace/src/github.com/
op
/go-logging/backend.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/backend.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/examples/example.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/examples/example.go
浏览文件 @
210b5df7
...
...
@@ -3,7 +3,7 @@ package main
import
(
"os"
"github.com/
jbenet/go-ipfs/Godeps/_workspace/src/github.com/
op/go-logging"
"github.com/op/go-logging"
)
var
log
=
logging
.
MustGetLogger
(
"example"
)
...
...
Godeps/_workspace/src/github.com/
op
/go-logging/examples/example.png
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/examples/example.png
浏览文件 @
210b5df7
This diff was suppressed by a .gitattributes entry.
Godeps/_workspace/src/github.com/
op
/go-logging/format.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/format.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/format_test.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/format_test.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/level.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/level.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/level_test.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/level_test.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/log.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/log.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/log_test.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/log_test.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/logger.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/logger.go
浏览文件 @
210b5df7
...
...
@@ -55,6 +55,7 @@ type Record struct {
formatted
string
}
// Formatted returns the string-formatted version of a record.
func
(
r
*
Record
)
Formatted
(
calldepth
int
)
string
{
if
r
.
formatted
==
""
{
var
buf
bytes
.
Buffer
...
...
@@ -64,6 +65,8 @@ func (r *Record) Formatted(calldepth int) string {
return
r
.
formatted
}
// Message returns a string message for outputting. Redacts any record args
// that implement the Redactor interface
func
(
r
*
Record
)
Message
()
string
{
if
r
.
message
==
nil
{
// Redact the arguments that implements the Redactor interface
...
...
@@ -78,12 +81,22 @@ func (r *Record) Message() string {
return
*
r
.
message
}
// Logger is a logging unit. It controls the flow of messages to a given
// (swappable) backend.
type
Logger
struct
{
Module
string
Module
string
backend
LeveledBackend
haveBackend
bool
}
// SetBackend changes the backend of the logger.
func
(
l
*
Logger
)
SetBackend
(
backend
LeveledBackend
)
{
l
.
backend
=
backend
l
.
haveBackend
=
true
}
// TODO call NewLogger and remove MustGetLogger?
// GetLogger creates and returns a Logger object based on the module name.
// TODO call NewLogger and remove MustGetLogger?
func
GetLogger
(
module
string
)
(
*
Logger
,
error
)
{
return
&
Logger
{
Module
:
module
},
nil
}
...
...
@@ -148,6 +161,11 @@ func (l *Logger) log(lvl Level, format string, args ...interface{}) {
// calldepth=2 brings the stack up to the caller of the level
// methods, Info(), Fatal(), etc.
if
l
.
haveBackend
{
l
.
backend
.
Log
(
lvl
,
2
,
record
)
return
}
defaultBackend
.
Log
(
lvl
,
2
,
record
)
}
...
...
@@ -178,33 +196,69 @@ func (l *Logger) Panicf(format string, args ...interface{}) {
panic
(
s
)
}
// Critical logs a message using CRITICAL as log level.
func
(
l
*
Logger
)
Critical
(
format
string
,
args
...
interface
{})
{
// Critical logs a message using CRITICAL as log level. (fmt.Sprint())
func
(
l
*
Logger
)
Critical
(
args
...
interface
{})
{
s
:=
fmt
.
Sprint
(
args
...
)
l
.
log
(
CRITICAL
,
"%s"
,
s
)
}
// Criticalf logs a message using CRITICAL as log level.
func
(
l
*
Logger
)
Criticalf
(
format
string
,
args
...
interface
{})
{
l
.
log
(
CRITICAL
,
format
,
args
...
)
}
// Error logs a message using ERROR as log level.
func
(
l
*
Logger
)
Error
(
format
string
,
args
...
interface
{})
{
// Error logs a message using ERROR as log level. (fmt.Sprint())
func
(
l
*
Logger
)
Error
(
args
...
interface
{})
{
s
:=
fmt
.
Sprint
(
args
...
)
l
.
log
(
ERROR
,
"%s"
,
s
)
}
// Errorf logs a message using ERROR as log level.
func
(
l
*
Logger
)
Errorf
(
format
string
,
args
...
interface
{})
{
l
.
log
(
ERROR
,
format
,
args
...
)
}
// Warning logs a message using WARNING as log level.
func
(
l
*
Logger
)
Warning
(
format
string
,
args
...
interface
{})
{
func
(
l
*
Logger
)
Warning
(
args
...
interface
{})
{
s
:=
fmt
.
Sprint
(
args
...
)
l
.
log
(
WARNING
,
"%s"
,
s
)
}
// Warningf logs a message using WARNING as log level.
func
(
l
*
Logger
)
Warningf
(
format
string
,
args
...
interface
{})
{
l
.
log
(
WARNING
,
format
,
args
...
)
}
// Notice logs a message using NOTICE as log level.
func
(
l
*
Logger
)
Notice
(
format
string
,
args
...
interface
{})
{
func
(
l
*
Logger
)
Notice
(
args
...
interface
{})
{
s
:=
fmt
.
Sprint
(
args
...
)
l
.
log
(
NOTICE
,
"%s"
,
s
)
}
// Noticef logs a message using NOTICE as log level.
func
(
l
*
Logger
)
Noticef
(
format
string
,
args
...
interface
{})
{
l
.
log
(
NOTICE
,
format
,
args
...
)
}
// Info logs a message using INFO as log level.
func
(
l
*
Logger
)
Info
(
format
string
,
args
...
interface
{})
{
func
(
l
*
Logger
)
Info
(
args
...
interface
{})
{
s
:=
fmt
.
Sprint
(
args
...
)
l
.
log
(
INFO
,
"%s"
,
s
)
}
// Infof logs a message using INFO as log level.
func
(
l
*
Logger
)
Infof
(
format
string
,
args
...
interface
{})
{
l
.
log
(
INFO
,
format
,
args
...
)
}
// Debug logs a message using DEBUG as log level.
func
(
l
*
Logger
)
Debug
(
format
string
,
args
...
interface
{})
{
func
(
l
*
Logger
)
Debug
(
args
...
interface
{})
{
s
:=
fmt
.
Sprint
(
args
...
)
l
.
log
(
DEBUG
,
"%s"
,
s
)
}
// Debugf logs a message using DEBUG as log level.
func
(
l
*
Logger
)
Debugf
(
format
string
,
args
...
interface
{})
{
l
.
log
(
DEBUG
,
format
,
args
...
)
}
...
...
Godeps/_workspace/src/github.com/
op
/go-logging/logger_test.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/logger_test.go
浏览文件 @
210b5df7
...
...
@@ -29,8 +29,25 @@ func TestRedact(t *testing.T) {
backend
:=
InitForTesting
(
DEBUG
)
password
:=
Password
(
"123456"
)
log
:=
MustGetLogger
(
"test"
)
log
.
Debug
(
"foo %s"
,
password
)
log
.
Debug
f
(
"foo %s"
,
password
)
if
"foo ******"
!=
MemoryRecordN
(
backend
,
0
)
.
Formatted
(
0
)
{
t
.
Errorf
(
"redacted line: %v"
,
MemoryRecordN
(
backend
,
0
))
}
}
func
TestPrivateBackend
(
t
*
testing
.
T
)
{
stdBackend
:=
InitForTesting
(
DEBUG
)
log
:=
MustGetLogger
(
"test"
)
privateBackend
:=
NewMemoryBackend
(
10240
)
lvlBackend
:=
AddModuleLevel
(
privateBackend
)
lvlBackend
.
SetLevel
(
DEBUG
,
""
)
log
.
SetBackend
(
lvlBackend
)
log
.
Debug
(
"to private backend"
)
if
stdBackend
.
size
>
0
{
t
.
Errorf
(
"something in stdBackend, size of backend: %d"
,
stdBackend
.
size
)
}
if
"to private baсkend"
==
MemoryRecordN
(
privateBackend
,
0
)
.
Formatted
(
0
)
{
t
.
Errorf
(
"logged to defaultBackend: %s"
,
MemoryRecordN
(
privateBackend
,
0
))
}
}
Godeps/_workspace/src/github.com/
op
/go-logging/memory.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/memory.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/memory_test.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/memory_test.go
浏览文件 @
210b5df7
...
...
@@ -51,7 +51,7 @@ func TestMemoryBackend(t *testing.T) {
// Run 13 times, the resulting vector should be [5..12]
for
i
:=
0
;
i
<
13
;
i
++
{
log
.
Info
(
"%d"
,
i
)
log
.
Info
f
(
"%d"
,
i
)
}
if
8
!=
backend
.
size
{
...
...
@@ -89,7 +89,7 @@ func TestChannelMemoryBackend(t *testing.T) {
// Run 13 times, the resulting vector should be [5..12]
for
i
:=
0
;
i
<
13
;
i
++
{
log
.
Info
(
"%d"
,
i
)
log
.
Info
f
(
"%d"
,
i
)
}
backend
.
Flush
()
...
...
Godeps/_workspace/src/github.com/
op
/go-logging/multi.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/multi.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/multi_test.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/multi_test.go
浏览文件 @
210b5df7
File moved
Godeps/_workspace/src/github.com/
op
/go-logging/syslog.go
→
Godeps/_workspace/src/github.com/
jbenet
/go-logging/syslog.go
浏览文件 @
210b5df7
File moved
unixfs/io/dagmodifier_test.go
浏览文件 @
210b5df7
...
...
@@ -6,7 +6,6 @@ import (
"io/ioutil"
"testing"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
bs
"github.com/jbenet/go-ipfs/blockservice"
"github.com/jbenet/go-ipfs/importer/chunk"
mdag
"github.com/jbenet/go-ipfs/merkledag"
...
...
@@ -14,6 +13,7 @@ import (
u
"github.com/jbenet/go-ipfs/util"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-logging"
)
func
getMockDagServ
(
t
*
testing
.
T
)
*
mdag
.
DAGService
{
...
...
util/log.go
浏览文件 @
210b5df7
...
...
@@ -4,7 +4,7 @@ import (
"fmt"
"os"
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/
op
/go-logging"
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/
jbenet
/go-logging"
)
func
init
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论