Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b5438e74
Commit
b5438e74
authored
Jul 12, 2021
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Debug level logging to Workhorse
parent
dc6a267a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
workhorse/internal/log/logging.go
workhorse/internal/log/logging.go
+8
-0
workhorse/internal/log/logging_test.go
workhorse/internal/log/logging_test.go
+11
-0
No files found.
workhorse/internal/log/logging.go
View file @
b5438e74
...
@@ -67,6 +67,14 @@ func (b *Builder) WithError(err error) *Builder {
...
@@ -67,6 +67,14 @@ func (b *Builder) WithError(err error) *Builder {
return
b
return
b
}
}
func
Debug
(
args
...
interface
{})
{
NewBuilder
()
.
Debug
(
args
...
)
}
func
(
b
*
Builder
)
Debug
(
args
...
interface
{})
{
b
.
entry
.
Debug
(
args
...
)
}
func
Info
(
args
...
interface
{})
{
func
Info
(
args
...
interface
{})
{
NewBuilder
()
.
Info
(
args
...
)
NewBuilder
()
.
Info
(
args
...
)
}
}
...
...
workhorse/internal/log/logging_test.go
View file @
b5438e74
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"net/http/httptest"
"testing"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -14,6 +15,7 @@ func captureLogs(b *Builder, testFn func()) string {
...
@@ -14,6 +15,7 @@ func captureLogs(b *Builder, testFn func()) string {
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
logger
:=
b
.
entry
.
Logger
logger
:=
b
.
entry
.
Logger
logger
.
SetLevel
(
logrus
.
DebugLevel
)
oldOut
:=
logger
.
Out
oldOut
:=
logger
.
Out
logger
.
Out
=
buf
logger
.
Out
=
buf
defer
func
()
{
defer
func
()
{
...
@@ -25,6 +27,15 @@ func captureLogs(b *Builder, testFn func()) string {
...
@@ -25,6 +27,15 @@ func captureLogs(b *Builder, testFn func()) string {
return
buf
.
String
()
return
buf
.
String
()
}
}
func
TestLogDebug
(
t
*
testing
.
T
)
{
b
:=
NewBuilder
()
logLine
:=
captureLogs
(
b
,
func
()
{
b
.
Debug
(
"an observation"
)
})
require
.
Regexp
(
t
,
`level=debug msg="an observation"`
,
logLine
)
}
func
TestLogInfo
(
t
*
testing
.
T
)
{
func
TestLogInfo
(
t
*
testing
.
T
)
{
b
:=
NewBuilder
()
b
:=
NewBuilder
()
logLine
:=
captureLogs
(
b
,
func
()
{
logLine
:=
captureLogs
(
b
,
func
()
{
...
...
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