Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
logger
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
go
logger
Commits
417e8897
Commit
417e8897
authored
Oct 12, 2022
by
yemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
416ace3a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
LogConf.go
log/LogConf.go
+17
-0
logger.go
log/logger.go
+10
-22
No files found.
log/LogConf.go
0 → 100644
View file @
417e8897
package
log
type
LogConfig
struct
{
// Debug、Info、Warn、Error
LogLevel
string
// true、false
LogColorful
bool
LogResponseLength
int
LogShowSql
bool
LogIndexNamePrefix
string
}
var
LogConf
=
LogConfig
{
"Debug"
,
true
,
0
,
true
,
""
}
log/logger.go
View file @
417e8897
...
@@ -9,18 +9,6 @@ import (
...
@@ -9,18 +9,6 @@ import (
"time"
"time"
)
)
// Debug、Info、Warn、Error
var
LogLevel
=
"DEBUG"
// true、false
var
LogColorful
=
true
var
LogResponseLength
int
var
LogShowSql
=
true
var
LogIndexNamePrefix
=
""
const
(
const
(
LevelDebug
=
"Debug"
LevelDebug
=
"Debug"
LevelInfo
=
"Info"
LevelInfo
=
"Info"
...
@@ -36,7 +24,7 @@ func DebugDo(f func()) {
...
@@ -36,7 +24,7 @@ func DebugDo(f func()) {
func
IsDebug
()
bool
{
func
IsDebug
()
bool
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -46,7 +34,7 @@ func IsDebug() bool {
...
@@ -46,7 +34,7 @@ func IsDebug() bool {
func
Debugf
(
format
string
,
msg
...
interface
{})
{
func
Debugf
(
format
string
,
msg
...
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -59,7 +47,7 @@ func Debugf(format string, msg ...interface{}) {
...
@@ -59,7 +47,7 @@ func Debugf(format string, msg ...interface{}) {
func
Debug
(
msg
interface
{})
{
func
Debug
(
msg
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -72,7 +60,7 @@ func Debug(msg interface{}) {
...
@@ -72,7 +60,7 @@ func Debug(msg interface{}) {
func
Infof
(
format
string
,
msg
...
interface
{})
{
func
Infof
(
format
string
,
msg
...
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -88,7 +76,7 @@ func Infof(format string, msg ...interface{}) {
...
@@ -88,7 +76,7 @@ func Infof(format string, msg ...interface{}) {
func
Info
(
msg
interface
{})
{
func
Info
(
msg
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -104,7 +92,7 @@ func Info(msg interface{}) {
...
@@ -104,7 +92,7 @@ func Info(msg interface{}) {
func
Warnf
(
format
string
,
msg
...
interface
{})
{
func
Warnf
(
format
string
,
msg
...
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -123,7 +111,7 @@ func Warnf(format string, msg ...interface{}) {
...
@@ -123,7 +111,7 @@ func Warnf(format string, msg ...interface{}) {
func
Warn
(
msg
interface
{})
{
func
Warn
(
msg
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -142,7 +130,7 @@ func Warn(msg interface{}) {
...
@@ -142,7 +130,7 @@ func Warn(msg interface{}) {
func
Errorf
(
format
string
,
msg
...
interface
{})
{
func
Errorf
(
format
string
,
msg
...
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -164,7 +152,7 @@ func Errorf(format string, msg ...interface{}) {
...
@@ -164,7 +152,7 @@ func Errorf(format string, msg ...interface{}) {
func
Error
(
msg
interface
{})
{
func
Error
(
msg
interface
{})
{
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
LogLevel
)
{
switch
strings
.
ToLower
(
Log
Conf
.
Log
Level
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
ok
=
true
break
break
...
@@ -202,7 +190,7 @@ const (
...
@@ -202,7 +190,7 @@ const (
func
print
(
tag
,
file
string
,
line
int
,
msg
interface
{})
{
func
print
(
tag
,
file
string
,
line
int
,
msg
interface
{})
{
str
:=
"%s %s [%d] %s %d %s"
str
:=
"%s %s [%d] %s %d %s"
if
LogColorful
{
if
LogCo
nf
.
LogCo
lorful
{
switch
tag
{
switch
tag
{
case
LevelDebug
:
case
LevelDebug
:
str
=
"%s %s [%d] %s %d "
+
green
+
"%s"
+
reset
str
=
"%s %s [%d] %s %d "
+
green
+
"%s"
+
reset
...
...
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