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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
conf/app.ini
pkg/setting/setting.go
conf/app.ini
View file @
6a5f4bf9
...
...
@@ -26,3 +26,7 @@ MaxIdle = 30
MaxActive
=
30
IdleTimeout
=
200
DBNum
=
0
[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 {
var
RedisSetting
=
&
Redis
{}
type
Log
struct
{
LogPath
string
LogChanSize
string
}
var
LogSetting
=
&
Log
{}
var
cfg
*
ini
.
File
// Setup initialize the configuration instance
func
Setup
()
{
var
err
error
cfg
,
err
=
ini
.
Load
(
"conf/app.ini"
)
...
...
@@ -75,6 +81,7 @@ func Setup() {
mapTo
(
"server"
,
ServerSetting
)
mapTo
(
"database"
,
DatabaseSetting
)
mapTo
(
"redis"
,
RedisSetting
)
mapTo
(
"log"
,
LogSetting
)
AppSetting
.
ImageMaxSize
=
AppSetting
.
ImageMaxSize
*
1024
*
1024
ServerSetting
.
ReadTimeout
=
ServerSetting
.
ReadTimeout
*
time
.
Second
...
...
@@ -82,7 +89,7 @@ func Setup() {
RedisSetting
.
IdleTimeout
=
RedisSetting
.
IdleTimeout
*
time
.
Second
}
//
mapTo map section
//
映射到配置文件的配置项
func
mapTo
(
section
string
,
v
interface
{})
{
err
:=
cfg
.
Section
(
section
)
.
MapTo
(
v
)
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