Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b1af2812
Unverified
Commit
b1af2812
authored
Dec 02, 2019
by
Arve Knudsen
Committed by
GitHub
Dec 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Server: Fail when unable to create log directory (#20804)
parent
8b7cd153
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
pkg/infra/log/log.go
+10
-4
pkg/setting/setting.go
+3
-4
No files found.
pkg/infra/log/log.go
View file @
b1af2812
...
...
@@ -12,6 +12,7 @@ import (
"github.com/go-stack/stack"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util/errutil"
"github.com/inconshreveable/log15"
isatty
"github.com/mattn/go-isatty"
"gopkg.in/ini.v1"
...
...
@@ -181,7 +182,7 @@ func getLogFormat(format string) log15.Format {
}
}
func
ReadLoggingConfig
(
modes
[]
string
,
logsPath
string
,
cfg
*
ini
.
File
)
{
func
ReadLoggingConfig
(
modes
[]
string
,
logsPath
string
,
cfg
*
ini
.
File
)
error
{
Close
()
defaultLevelName
,
_
:=
getLogLevelFromConfig
(
"log"
,
"info"
,
cfg
)
...
...
@@ -194,6 +195,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
sec
,
err
:=
cfg
.
GetSection
(
"log."
+
mode
)
if
err
!=
nil
{
Root
.
Error
(
"Unknown log mode"
,
"mode"
,
mode
)
return
errutil
.
Wrapf
(
err
,
"failed to get config section log.%s"
,
mode
)
}
// Log level.
...
...
@@ -212,7 +214,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
dpath
:=
filepath
.
Dir
(
fileName
)
if
err
:=
os
.
MkdirAll
(
dpath
,
os
.
ModePerm
);
err
!=
nil
{
Root
.
Error
(
"Failed to create directory"
,
"dpath"
,
dpath
,
"err"
,
err
)
break
return
errutil
.
Wrapf
(
err
,
"failed to create log directory %q"
,
dpath
)
}
fileHandler
:=
NewFileWriter
()
fileHandler
.
Filename
=
fileName
...
...
@@ -223,8 +225,8 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
fileHandler
.
Daily
=
sec
.
Key
(
"daily_rotate"
)
.
MustBool
(
true
)
fileHandler
.
Maxdays
=
sec
.
Key
(
"max_days"
)
.
MustInt64
(
7
)
if
err
:=
fileHandler
.
Init
();
err
!=
nil
{
Root
.
Error
(
"Failed to
create directory
"
,
"dpath"
,
dpath
,
"err"
,
err
)
break
Root
.
Error
(
"Failed to
initialize file handler
"
,
"dpath"
,
dpath
,
"err"
,
err
)
return
errutil
.
Wrapf
(
err
,
"failed to initialize file handler"
)
}
loggersToClose
=
append
(
loggersToClose
,
fileHandler
)
...
...
@@ -236,6 +238,9 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
loggersToClose
=
append
(
loggersToClose
,
sysLogHandler
)
handler
=
sysLogHandler
}
if
handler
==
nil
{
panic
(
fmt
.
Sprintf
(
"Handler is uninitialized for mode %q"
,
mode
))
}
for
key
,
value
:=
range
defaultFilters
{
if
_
,
exist
:=
modeFilters
[
key
];
!
exist
{
...
...
@@ -254,6 +259,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
}
Root
.
SetHandler
(
log15
.
MultiHandler
(
handlers
...
))
return
nil
}
func
LogFilterHandler
(
maxLevel
log15
.
Lvl
,
filters
map
[
string
]
log15
.
Lvl
,
h
log15
.
Handler
)
log15
.
Handler
{
...
...
pkg/setting/setting.go
View file @
b1af2812
...
...
@@ -444,7 +444,7 @@ func evalConfigValues(file *ini.File) {
}
}
func
loadSpecifedConfigFile
(
configFile
string
,
masterFile
*
ini
.
File
)
error
{
func
loadSpecif
i
edConfigFile
(
configFile
string
,
masterFile
*
ini
.
File
)
error
{
if
configFile
==
""
{
configFile
=
filepath
.
Join
(
HomePath
,
CustomInitPath
)
// return without error if custom file does not exist
...
...
@@ -511,7 +511,7 @@ func (cfg *Cfg) loadConfiguration(args *CommandLineArgs) (*ini.File, error) {
applyCommandLineDefaultProperties
(
commandLineProps
,
parsedFile
)
// load specified config file
err
=
loadSpecifedConfigFile
(
args
.
Config
,
parsedFile
)
err
=
loadSpecif
i
edConfigFile
(
args
.
Config
,
parsedFile
)
if
err
!=
nil
{
err2
:=
cfg
.
initLogging
(
parsedFile
)
if
err2
!=
nil
{
...
...
@@ -1083,8 +1083,7 @@ func (cfg *Cfg) initLogging(file *ini.File) error {
return
err
}
cfg
.
LogsPath
=
makeAbsolute
(
logsPath
,
HomePath
)
log
.
ReadLoggingConfig
(
logModes
,
cfg
.
LogsPath
,
file
)
return
nil
return
log
.
ReadLoggingConfig
(
logModes
,
cfg
.
LogsPath
,
file
)
}
func
(
cfg
*
Cfg
)
LogConfigSources
()
{
...
...
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