Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
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
zhengqiuyun
rym-util
Commits
01c86bd1
Commit
01c86bd1
authored
Aug 25, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql加入连接配置
parent
13557f1d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
logger.go
log/logger.go
+18
-5
main.go
main.go
+6
-0
No files found.
log/logger.go
View file @
01c86bd1
...
@@ -50,6 +50,8 @@ func Info(msg string) {
...
@@ -50,6 +50,8 @@ func Info(msg string) {
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
conf
.
LogLevel
)
{
switch
strings
.
ToLower
(
conf
.
LogLevel
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
break
case
strings
.
ToLower
(
LevelInfo
)
:
case
strings
.
ToLower
(
LevelInfo
)
:
ok
=
true
ok
=
true
break
break
...
@@ -64,7 +66,11 @@ func Warn(msg string) {
...
@@ -64,7 +66,11 @@ func Warn(msg string) {
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
conf
.
LogLevel
)
{
switch
strings
.
ToLower
(
conf
.
LogLevel
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
break
case
strings
.
ToLower
(
LevelInfo
)
:
case
strings
.
ToLower
(
LevelInfo
)
:
ok
=
true
break
case
strings
.
ToLower
(
LevelWarn
)
:
case
strings
.
ToLower
(
LevelWarn
)
:
ok
=
true
ok
=
true
break
break
...
@@ -79,8 +85,14 @@ func Error(msg string) {
...
@@ -79,8 +85,14 @@ func Error(msg string) {
ok
:=
false
ok
:=
false
switch
strings
.
ToLower
(
conf
.
LogLevel
)
{
switch
strings
.
ToLower
(
conf
.
LogLevel
)
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
strings
.
ToLower
(
LevelDebug
)
:
ok
=
true
break
case
strings
.
ToLower
(
LevelInfo
)
:
case
strings
.
ToLower
(
LevelInfo
)
:
ok
=
true
break
case
strings
.
ToLower
(
LevelWarn
)
:
case
strings
.
ToLower
(
LevelWarn
)
:
ok
=
true
break
case
strings
.
ToLower
(
LevelError
)
:
case
strings
.
ToLower
(
LevelError
)
:
ok
=
true
ok
=
true
break
break
...
@@ -111,15 +123,16 @@ func print(tag, msg string, file string, line int) {
...
@@ -111,15 +123,16 @@ func print(tag, msg string, file string, line int) {
str
:=
"%s %s [%d] %s %d %s"
str
:=
"%s %s [%d] %s %d %s"
if
conf
.
LogColorful
{
if
conf
.
LogColorful
{
switch
tag
{
switch
tag
{
case
strings
.
ToLower
(
LevelDebug
)
:
case
LevelDebug
:
str
=
"%s %s [%d] %s %d "
+
green
+
"%s"
+
reset
str
=
"%s %s [%d] %s %d "
+
green
+
"%s"
+
reset
break
break
case
strings
.
ToLower
(
LevelInfo
)
:
case
LevelInfo
:
break
case
strings
.
ToLower
(
LevelWarn
)
:
str
=
"%s %s [%d] %s %d "
+
yellow
+
"%s"
+
reset
str
=
"%s %s [%d] %s %d "
+
yellow
+
"%s"
+
reset
break
break
case
strings
.
ToLower
(
LevelError
)
:
case
LevelWarn
:
str
=
"%s %s [%d] %s %d "
+
magenta
+
"%s"
+
reset
break
case
LevelError
:
str
=
"%s %s [%d] %s %d "
+
red
+
"%s"
+
reset
str
=
"%s %s [%d] %s %d "
+
red
+
"%s"
+
reset
break
break
}
}
...
...
main.go
View file @
01c86bd1
...
@@ -3,16 +3,22 @@ package main
...
@@ -3,16 +3,22 @@ package main
import
(
import
(
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/es"
"git.168cad.top/zhengqiuyun/rym-util/es"
"git.168cad.top/zhengqiuyun/rym-util/log"
"git.168cad.top/zhengqiuyun/rym-util/mysqlrym"
"git.168cad.top/zhengqiuyun/rym-util/mysqlrym"
"git.168cad.top/zhengqiuyun/rym-util/redis"
"git.168cad.top/zhengqiuyun/rym-util/redis"
"git.168cad.top/zhengqiuyun/rym-util/router"
"git.168cad.top/zhengqiuyun/rym-util/router"
)
)
func
main
()
{
func
main
()
{
log
.
Debug
(
"测试"
)
log
.
Info
(
"测试"
)
log
.
Warn
(
"测试"
)
log
.
Error
(
"测试"
)
conf
.
BaseConfig
(
conf
.
Config
{
conf
.
BaseConfig
(
conf
.
Config
{
ServerName
:
"rym-framework"
,
ServerName
:
"rym-framework"
,
Env
:
"dev"
,
Env
:
"dev"
,
HttpPort
:
1024
,
HttpPort
:
1024
,
LogColorful
:
true
,
})
})
mysqlrym
.
TestLog
()
mysqlrym
.
TestLog
()
es
.
TestLog
()
es
.
TestLog
()
...
...
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