Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
2d9550f2
Commit
2d9550f2
authored
Jan 31, 2015
by
Juan Batiz-Benet
Committed by
Brian Tiger Chow
Feb 01, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(eventlog) add *EventInProgress.Append method
parent
68a00794
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
thirdparty/eventlog/log.go
thirdparty/eventlog/log.go
+7
-7
No files found.
thirdparty/eventlog/log.go
View file @
2d9550f2
...
...
@@ -49,7 +49,7 @@ type EventLogger interface {
// the metadata is logged.
Event
(
ctx
context
.
Context
,
event
string
,
m
...
Loggable
)
EventBegin
(
ctx
context
.
Context
,
event
string
,
m
...
Loggable
)
EventInProgress
EventBegin
(
ctx
context
.
Context
,
event
string
,
m
...
Loggable
)
*
EventInProgress
}
// Logger retrieves an event logger by name
...
...
@@ -68,11 +68,11 @@ type eventLogger struct {
// TODO add log-level
}
func
(
el
*
eventLogger
)
EventBegin
(
ctx
context
.
Context
,
event
string
,
metadata
...
Loggable
)
EventInProgress
{
func
(
el
*
eventLogger
)
EventBegin
(
ctx
context
.
Context
,
event
string
,
metadata
...
Loggable
)
*
EventInProgress
{
start
:=
time
.
Now
()
el
.
Event
(
ctx
,
fmt
.
Sprintf
(
"%sBegin"
,
event
),
metadata
...
)
eip
:=
EventInProgress
{}
eip
:=
&
EventInProgress
{}
eip
.
doneFunc
=
func
(
additional
[]
Loggable
)
{
metadata
=
append
(
metadata
,
additional
...
)
// anything added during the operation
...
...
@@ -116,12 +116,12 @@ type EventInProgress struct {
}
// Append adds loggables to be included in the call to Done
func
(
eip
EventInProgress
)
Append
(
l
Loggable
)
{
func
(
eip
*
EventInProgress
)
Append
(
l
Loggable
)
{
eip
.
loggables
=
append
(
eip
.
loggables
,
l
)
}
// SetError includes the provided error
func
(
eip
EventInProgress
)
SetError
(
err
error
)
{
func
(
eip
*
EventInProgress
)
SetError
(
err
error
)
{
eip
.
loggables
=
append
(
eip
.
loggables
,
LoggableMap
{
"error"
:
err
.
Error
(),
})
...
...
@@ -129,12 +129,12 @@ func (eip EventInProgress) SetError(err error) {
// Done creates a new Event entry that includes the duration and appended
// loggables.
func
(
eip
EventInProgress
)
Done
()
{
func
(
eip
*
EventInProgress
)
Done
()
{
eip
.
doneFunc
(
eip
.
loggables
)
// create final event with extra data
}
// Close is an alias for done
func
(
eip
EventInProgress
)
Close
()
error
{
func
(
eip
*
EventInProgress
)
Close
()
error
{
eip
.
Done
()
return
nil
}
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