Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3d9cc316
Commit
3d9cc316
authored
Nov 06, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update glog package to get *Depth() functions.
parent
5d003607
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
6 deletions
+88
-6
Godeps.json
Godeps/Godeps.json
+1
-1
glog.go
Godeps/_workspace/src/github.com/golang/glog/glog.go
+0
-0
glog_test.go
Godeps/_workspace/src/github.com/golang/glog/glog_test.go
+87
-5
No files found.
Godeps/Godeps.json
View file @
3d9cc316
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
},
},
{
{
"ImportPath"
:
"github.com/golang/glog"
,
"ImportPath"
:
"github.com/golang/glog"
,
"Rev"
:
"
d1c4472bf2efd3826f2b5bdcc02d8416798d678c
"
"Rev"
:
"
44145f04b68cf362d9c4df2182967c2275eaefed
"
},
},
{
{
"ImportPath"
:
"github.com/google/cadvisor/client"
,
"ImportPath"
:
"github.com/google/cadvisor/client"
,
...
...
Godeps/_workspace/src/github.com/golang/glog/glog.go
View file @
3d9cc316
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/golang/glog/glog_test.go
View file @
3d9cc316
...
@@ -19,8 +19,10 @@ package glog
...
@@ -19,8 +19,10 @@ package glog
import
(
import
(
"bytes"
"bytes"
"fmt"
"fmt"
stdLog
"log"
"path/filepath"
"path/filepath"
"runtime"
"runtime"
"strconv"
"strings"
"strings"
"testing"
"testing"
"time"
"time"
...
@@ -96,20 +98,99 @@ func TestInfo(t *testing.T) {
...
@@ -96,20 +98,99 @@ func TestInfo(t *testing.T) {
}
}
}
}
func
TestInfoDepth
(
t
*
testing
.
T
)
{
setFlags
()
defer
logging
.
swap
(
logging
.
newBuffers
())
f
:=
func
()
{
InfoDepth
(
1
,
"depth-test1"
)
}
// The next three lines must stay together
_
,
_
,
wantLine
,
_
:=
runtime
.
Caller
(
0
)
InfoDepth
(
0
,
"depth-test0"
)
f
()
msgs
:=
strings
.
Split
(
strings
.
TrimSuffix
(
contents
(
infoLog
),
"
\n
"
),
"
\n
"
)
if
len
(
msgs
)
!=
2
{
t
.
Fatalf
(
"Got %d lines, expected 2"
,
len
(
msgs
))
}
for
i
,
m
:=
range
msgs
{
if
!
strings
.
HasPrefix
(
m
,
"I"
)
{
t
.
Errorf
(
"InfoDepth[%d] has wrong character: %q"
,
i
,
m
)
}
w
:=
fmt
.
Sprintf
(
"depth-test%d"
,
i
)
if
!
strings
.
Contains
(
m
,
w
)
{
t
.
Errorf
(
"InfoDepth[%d] missing %q: %q"
,
i
,
w
,
m
)
}
// pull out the line number (between : and ])
msg
:=
m
[
strings
.
LastIndex
(
m
,
":"
)
+
1
:
]
x
:=
strings
.
Index
(
msg
,
"]"
)
if
x
<
0
{
t
.
Errorf
(
"InfoDepth[%d]: missing ']': %q"
,
i
,
m
)
continue
}
line
,
err
:=
strconv
.
Atoi
(
msg
[
:
x
])
if
err
!=
nil
{
t
.
Errorf
(
"InfoDepth[%d]: bad line number: %q"
,
i
,
m
)
continue
}
wantLine
++
if
wantLine
!=
line
{
t
.
Errorf
(
"InfoDepth[%d]: got line %d, want %d"
,
i
,
line
,
wantLine
)
}
}
}
func
init
()
{
CopyStandardLogTo
(
"INFO"
)
}
// Test that CopyStandardLogTo panics on bad input.
func
TestCopyStandardLogToPanic
(
t
*
testing
.
T
)
{
defer
func
()
{
if
s
,
ok
:=
recover
()
.
(
string
);
!
ok
||
!
strings
.
Contains
(
s
,
"LOG"
)
{
t
.
Errorf
(
`CopyStandardLogTo("LOG") should have panicked: %v`
,
s
)
}
}()
CopyStandardLogTo
(
"LOG"
)
}
// Test that using the standard log package logs to INFO.
func
TestStandardLog
(
t
*
testing
.
T
)
{
setFlags
()
defer
logging
.
swap
(
logging
.
newBuffers
())
stdLog
.
Print
(
"test"
)
if
!
contains
(
infoLog
,
"I"
,
t
)
{
t
.
Errorf
(
"Info has wrong character: %q"
,
contents
(
infoLog
))
}
if
!
contains
(
infoLog
,
"test"
,
t
)
{
t
.
Error
(
"Info failed"
)
}
}
// Test that the header has the correct format.
// Test that the header has the correct format.
func
TestHeader
(
t
*
testing
.
T
)
{
func
TestHeader
(
t
*
testing
.
T
)
{
setFlags
()
setFlags
()
defer
logging
.
swap
(
logging
.
newBuffers
())
defer
logging
.
swap
(
logging
.
newBuffers
())
defer
func
(
previous
func
()
time
.
Time
)
{
timeNow
=
previous
}(
timeNow
)
defer
func
(
previous
func
()
time
.
Time
)
{
timeNow
=
previous
}(
timeNow
)
timeNow
=
func
()
time
.
Time
{
timeNow
=
func
()
time
.
Time
{
return
time
.
Date
(
2006
,
1
,
2
,
15
,
4
,
5
,
.
678901
e9
,
time
.
Local
)
return
time
.
Date
(
2006
,
1
,
2
,
15
,
4
,
5
,
.
067890
e9
,
time
.
Local
)
}
}
pid
=
1234
Info
(
"test"
)
Info
(
"test"
)
var
line
,
pid
int
var
line
int
n
,
err
:=
fmt
.
Sscanf
(
contents
(
infoLog
),
"I0102 15:04:05.678901 %d glog_test.go:%d] test
\n
"
,
&
pid
,
&
line
)
format
:=
"I0102 15:04:05.067890 1234 glog_test.go:%d] test
\n
"
if
n
!=
2
||
err
!=
nil
{
n
,
err
:=
fmt
.
Sscanf
(
contents
(
infoLog
),
format
,
&
line
)
if
n
!=
1
||
err
!=
nil
{
t
.
Errorf
(
"log format error: %d elements, error %s:
\n
%s"
,
n
,
err
,
contents
(
infoLog
))
t
.
Errorf
(
"log format error: %d elements, error %s:
\n
%s"
,
n
,
err
,
contents
(
infoLog
))
}
}
// Scanf treats multiple spaces as equivalent to a single space,
// so check for correct space-padding also.
want
:=
fmt
.
Sprintf
(
format
,
line
)
if
contents
(
infoLog
)
!=
want
{
t
.
Errorf
(
"log format error: got:
\n\t
%q
\n
want:
\t
%q"
,
contents
(
infoLog
),
want
)
}
}
}
// Test that an Error log goes to Warning and Info.
// Test that an Error log goes to Warning and Info.
...
@@ -328,6 +409,7 @@ func TestLogBacktraceAt(t *testing.T) {
...
@@ -328,6 +409,7 @@ func TestLogBacktraceAt(t *testing.T) {
func
BenchmarkHeader
(
b
*
testing
.
B
)
{
func
BenchmarkHeader
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
logging
.
putBuffer
(
logging
.
header
(
infoLog
))
buf
,
_
,
_
:=
logging
.
header
(
infoLog
,
0
)
logging
.
putBuffer
(
buf
)
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment