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
7f84f33c
Commit
7f84f33c
authored
3 years ago
by
Cornel Rautenbach
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup
parent
20799cce
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
logger/db.go
+2
-2
2 additions, 2 deletions
logger/db.go
logger/fields.go
+0
-3
0 additions, 3 deletions
logger/fields.go
logger/format.go
+1
-11
1 addition, 11 deletions
logger/format.go
with
3 additions
and
16 deletions
logger/db.go
+
2
−
2
View file @
7f84f33c
...
@@ -9,11 +9,11 @@ import (
...
@@ -9,11 +9,11 @@ import (
type
DbLogger
struct
{}
type
DbLogger
struct
{}
func
(
d
DbLogger
)
BeforeQuery
(
c
context
.
Context
,
q
*
pg
.
QueryEvent
)
(
context
.
Context
,
error
)
{
func
(
d
DbLogger
)
BeforeQuery
(
c
context
.
Context
,
_
*
pg
.
QueryEvent
)
(
context
.
Context
,
error
)
{
return
c
,
nil
return
c
,
nil
}
}
func
(
d
DbLogger
)
AfterQuery
(
c
context
.
Context
,
q
*
pg
.
QueryEvent
)
error
{
func
(
d
DbLogger
)
AfterQuery
(
_
context
.
Context
,
q
*
pg
.
QueryEvent
)
error
{
sql
,
_
:=
q
.
FormattedQuery
()
sql
,
_
:=
q
.
FormattedQuery
()
if
os
.
Getenv
(
"DEBUGGING"
)
==
"true"
{
if
os
.
Getenv
(
"DEBUGGING"
)
==
"true"
{
Debugf
(
string
(
sql
))
Debugf
(
string
(
sql
))
...
...
This diff is collapsed.
Click to expand it.
logger/fields.go
deleted
100644 → 0
+
0
−
3
View file @
20799cce
package
logger
type
Fields
map
[
string
]
interface
{}
This diff is collapsed.
Click to expand it.
logger/format.go
+
1
−
11
View file @
7f84f33c
...
@@ -16,10 +16,6 @@ type IFormatter interface {
...
@@ -16,10 +16,6 @@ type IFormatter interface {
Color
()
string
Color
()
string
}
}
func
NewJSON
()
IFormatter
{
return
formatterJSON
{}
}
type
formatterJSON
struct
{}
type
formatterJSON
struct
{}
func
(
f
formatterJSON
)
Format
(
entry
Entry
)
[]
byte
{
func
(
f
formatterJSON
)
Format
(
entry
Entry
)
[]
byte
{
...
@@ -64,7 +60,6 @@ func (f formatterConsole) Format(entry Entry) []byte {
...
@@ -64,7 +60,6 @@ func (f formatterConsole) Format(entry Entry) []byte {
red
:=
color
.
New
(
color
.
FgRed
)
.
FprintfFunc
()
red
:=
color
.
New
(
color
.
FgRed
)
.
FprintfFunc
()
magenta
:=
color
.
New
(
color
.
FgMagenta
)
.
FprintfFunc
()
magenta
:=
color
.
New
(
color
.
FgMagenta
)
.
FprintfFunc
()
yellow
:=
color
.
New
(
color
.
FgYellow
)
.
FprintfFunc
()
yellow
:=
color
.
New
(
color
.
FgYellow
)
.
FprintfFunc
()
//blue := color.New(color.FgBlue).FprintfFunc()
green
:=
color
.
New
(
color
.
FgGreen
)
.
FprintfFunc
()
green
:=
color
.
New
(
color
.
FgGreen
)
.
FprintfFunc
()
cyan
:=
color
.
New
(
color
.
FgCyan
)
.
FprintfFunc
()
cyan
:=
color
.
New
(
color
.
FgCyan
)
.
FprintfFunc
()
...
@@ -86,7 +81,7 @@ func (f formatterConsole) Format(entry Entry) []byte {
...
@@ -86,7 +81,7 @@ func (f formatterConsole) Format(entry Entry) []byte {
cyan
(
buffer
,
fmt
.
Sprintf
(
" %-40.40s| "
,
source
))
cyan
(
buffer
,
fmt
.
Sprintf
(
" %-40.40s| "
,
source
))
base
:=
color
.
New
(
fgColors
[
colorNames
[
f
.
fg
]],
bgColors
[
colorNames
[
f
.
bg
]])
.
FprintfFunc
()
base
:=
color
.
New
(
fgColors
[
colorNames
[
f
.
fg
]],
bgColors
[
colorNames
[
f
.
bg
]])
.
FprintfFunc
()
base
(
buffer
,
entry
.
Message
)
//buffer.Write([]byte(entry.Message))
base
(
buffer
,
entry
.
Message
)
if
len
(
entry
.
Data
)
>
0
{
if
len
(
entry
.
Data
)
>
0
{
jsonData
,
_
:=
json
.
Marshal
(
entry
.
Data
)
jsonData
,
_
:=
json
.
Marshal
(
entry
.
Data
)
...
@@ -141,10 +136,6 @@ func (f formatterConsole) NextColor() IFormatter {
...
@@ -141,10 +136,6 @@ func (f formatterConsole) NextColor() IFormatter {
nextFg
++
nextFg
++
if
nextFg
>=
len
(
fgColors
)
{
if
nextFg
>=
len
(
fgColors
)
{
nextFg
=
0
nextFg
=
0
// nextBg++
// if nextBg >= len(bgColors) {
// nextBg++
// }
}
}
if
nextFg
!=
nextBg
{
if
nextFg
!=
nextBg
{
break
break
...
@@ -156,6 +147,5 @@ func (f formatterConsole) NextColor() IFormatter {
...
@@ -156,6 +147,5 @@ func (f formatterConsole) NextColor() IFormatter {
fg
:
nextFg
,
fg
:
nextFg
,
bg
:
nextBg
,
bg
:
nextBg
,
}
}
//globalLogger.Debugf("NextColor return id=%d Color %s on %s", f.id, colorNames[f.fg], colorNames[f.bg])
return
f
return
f
}
}
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