Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
82320944
Commit
82320944
authored
4 months ago
by
Francé Wilke
Browse files
Options
Downloads
Patches
Plain Diff
Change ErrorWithMsg and ErrorWithFields to cater for formatting directives
parent
413c354e
Branches
Branches containing commit
Tags
v1.272.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
logs/logs.go
+9
-6
9 additions, 6 deletions
logs/logs.go
with
9 additions
and
6 deletions
logs/logs.go
+
9
−
6
View file @
82320944
...
@@ -226,7 +226,7 @@ func Info(format string, a ...interface{}) {
...
@@ -226,7 +226,7 @@ func Info(format string, a ...interface{}) {
}
}
}
}
func
ErrorWithFields
(
fields
map
[
string
]
interface
{}
,
err
error
)
{
func
ErrorWithFields
(
err
error
,
fields
map
[
string
]
interface
{})
{
if
disableLogging
{
if
disableLogging
{
return
return
}
}
...
@@ -242,17 +242,20 @@ func ErrorWithFields(fields map[string]interface{}, err error) {
...
@@ -242,17 +242,20 @@ func ErrorWithFields(fields map[string]interface{}, err error) {
}
}
}
}
func
ErrorWithMsg
(
message
string
,
err
error
)
{
func
ErrorWithMsg
(
err
error
,
format
string
,
a
...
interface
{}
)
{
if
disableLogging
{
if
disableLogging
{
return
return
}
}
message
:=
fmt
.
Sprintf
(
format
,
a
...
)
if
err
==
nil
{
if
err
==
nil
{
err
=
errors
.
Error
(
message
)
err
=
errors
.
Error
(
message
)
}
}
ErrorWithFields
(
map
[
string
]
interface
{}{
ErrorWithFields
(
err
,
map
[
string
]
interface
{}{
"message"
:
message
,
"message"
:
message
,
}
,
err
)
})
}
}
func
ErrorMsg
(
format
string
,
a
...
interface
{})
{
func
ErrorMsg
(
format
string
,
a
...
interface
{})
{
...
@@ -262,7 +265,7 @@ func ErrorMsg(format string, a ...interface{}) {
...
@@ -262,7 +265,7 @@ func ErrorMsg(format string, a ...interface{}) {
message
:=
SanitiseLogs
(
fmt
.
Sprintf
(
format
,
a
...
))
message
:=
SanitiseLogs
(
fmt
.
Sprintf
(
format
,
a
...
))
ErrorWithMsg
(
message
,
nil
)
ErrorWithMsg
(
nil
,
message
)
}
}
func
Warn
(
format
string
,
a
...
interface
{})
{
func
Warn
(
format
string
,
a
...
interface
{})
{
...
@@ -280,7 +283,7 @@ func Warn(format string, a ...interface{}) {
...
@@ -280,7 +283,7 @@ func Warn(format string, a ...interface{}) {
}
}
}
}
func
WarnWithFields
(
fields
map
[
string
]
interface
{}
,
err
error
)
{
func
WarnWithFields
(
err
error
,
fields
map
[
string
]
interface
{})
{
if
disableLogging
{
if
disableLogging
{
return
return
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment