Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_soapi
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6a5f4bf9
authored
Jan 06, 2020
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
日志配置文件
parent
a44a403c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
conf/app.ini
pkg/setting/setting.go
conf/app.ini
View file @
6a5f4bf9
...
@@ -25,4 +25,8 @@ Password =
...
@@ -25,4 +25,8 @@ Password =
MaxIdle
=
30
MaxIdle
=
30
MaxActive
=
30
MaxActive
=
30
IdleTimeout
=
200
IdleTimeout
=
200
DBNum
=
0
DBNum
=
0
\ No newline at end of file
[log]
LogPath
=
'logs/'
LogChanSize
=
1000
\ No newline at end of file
pkg/setting/setting.go
View file @
6a5f4bf9
...
@@ -61,9 +61,15 @@ type Redis struct {
...
@@ -61,9 +61,15 @@ type Redis struct {
var
RedisSetting
=
&
Redis
{}
var
RedisSetting
=
&
Redis
{}
type
Log
struct
{
LogPath
string
LogChanSize
string
}
var
LogSetting
=
&
Log
{}
var
cfg
*
ini
.
File
var
cfg
*
ini
.
File
// Setup initialize the configuration instance
func
Setup
()
{
func
Setup
()
{
var
err
error
var
err
error
cfg
,
err
=
ini
.
Load
(
"conf/app.ini"
)
cfg
,
err
=
ini
.
Load
(
"conf/app.ini"
)
...
@@ -75,6 +81,7 @@ func Setup() {
...
@@ -75,6 +81,7 @@ func Setup() {
mapTo
(
"server"
,
ServerSetting
)
mapTo
(
"server"
,
ServerSetting
)
mapTo
(
"database"
,
DatabaseSetting
)
mapTo
(
"database"
,
DatabaseSetting
)
mapTo
(
"redis"
,
RedisSetting
)
mapTo
(
"redis"
,
RedisSetting
)
mapTo
(
"log"
,
LogSetting
)
AppSetting
.
ImageMaxSize
=
AppSetting
.
ImageMaxSize
*
1024
*
1024
AppSetting
.
ImageMaxSize
=
AppSetting
.
ImageMaxSize
*
1024
*
1024
ServerSetting
.
ReadTimeout
=
ServerSetting
.
ReadTimeout
*
time
.
Second
ServerSetting
.
ReadTimeout
=
ServerSetting
.
ReadTimeout
*
time
.
Second
...
@@ -82,7 +89,7 @@ func Setup() {
...
@@ -82,7 +89,7 @@ func Setup() {
RedisSetting
.
IdleTimeout
=
RedisSetting
.
IdleTimeout
*
time
.
Second
RedisSetting
.
IdleTimeout
=
RedisSetting
.
IdleTimeout
*
time
.
Second
}
}
//
mapTo map section
//
映射到配置文件的配置项
func
mapTo
(
section
string
,
v
interface
{})
{
func
mapTo
(
section
string
,
v
interface
{})
{
err
:=
cfg
.
Section
(
section
)
.
MapTo
(
v
)
err
:=
cfg
.
Section
(
section
)
.
MapTo
(
v
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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