Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-socketCenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
hujiebin
hilo-socketCenter
Commits
587cdf55
You need to sign in or sign up before continuing.
Commit
587cdf55
authored
Sep 02, 2023
by
JiebinHu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:去掉logger
parent
1f06749b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
mysql.go
common/mysql/mysql.go
+10
-12
No files found.
common/mysql/mysql.go
View file @
587cdf55
...
@@ -6,10 +6,8 @@ import (
...
@@ -6,10 +6,8 @@ import (
_
"github.com/joho/godotenv/autoload"
_
"github.com/joho/godotenv/autoload"
"gorm.io/driver/mysql"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
"gorm.io/gorm/schema"
"hilo-socketCenter/common/config"
"hilo-socketCenter/common/config"
"hilo-socketCenter/common/mylogrus"
"log"
"log"
"net/url"
"net/url"
"time"
"time"
...
@@ -23,18 +21,18 @@ func init() {
...
@@ -23,18 +21,18 @@ func init() {
options
:=
"?charset=utf8mb4&parseTime=True&loc=Local&time_zone="
+
url
.
QueryEscape
(
"'+8:00'"
)
options
:=
"?charset=utf8mb4&parseTime=True&loc=Local&time_zone="
+
url
.
QueryEscape
(
"'+8:00'"
)
dsn
:=
""
+
mysqlConfigData
.
MYSQL_USERNAME
+
":"
+
mysqlConfigData
.
MYSQL_PASSWORD
+
"@("
+
mysqlConfigData
.
MYSQL_HOST
+
")/"
+
mysqlConfigData
.
MYSQL_DB
+
options
dsn
:=
""
+
mysqlConfigData
.
MYSQL_USERNAME
+
":"
+
mysqlConfigData
.
MYSQL_PASSWORD
+
"@("
+
mysqlConfigData
.
MYSQL_HOST
+
")/"
+
mysqlConfigData
.
MYSQL_DB
+
options
sqlLogger
:=
logger
.
Default
.
LogMode
(
logger
.
Error
)
// 这个服务不需要
//
sqlLogger := logger.Default.LogMode(logger.Error) // 这个服务不需要
if
file
:=
mylogrus
.
GetSqlLog
();
file
!=
nil
{
//
if file := mylogrus.GetSqlLog(); file != nil {
//sqlLogger = logger.New(log.New(file, "\r\n", log.Ldate|log.Lmicroseconds), logger.Config{
//
//sqlLogger = logger.New(log.New(file, "\r\n", log.Ldate|log.Lmicroseconds), logger.Config{
sqlLogger
=
MyNew
(
log
.
New
(
file
,
""
,
log
.
Ldate
|
log
.
Lmicroseconds
),
logger
.
Config
{
//
sqlLogger = MyNew(log.New(file, "", log.Ldate|log.Lmicroseconds), logger.Config{
SlowThreshold
:
200
*
time
.
Millisecond
,
//
SlowThreshold: 200 * time.Millisecond,
LogLevel
:
logger
.
Info
,
//
LogLevel: logger.Info,
Colorful
:
false
,
//
Colorful: false,
})
//
})
}
//
}
Db
,
err
=
gorm
.
Open
(
mysql
.
Open
(
dsn
),
&
gorm
.
Config
{
Db
,
err
=
gorm
.
Open
(
mysql
.
Open
(
dsn
),
&
gorm
.
Config
{
Logger
:
sqlLogger
,
//
Logger: sqlLogger,
NamingStrategy
:
schema
.
NamingStrategy
{
NamingStrategy
:
schema
.
NamingStrategy
{
SingularTable
:
true
,
SingularTable
:
true
,
},
},
...
...
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