mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Deduplicate logfile opening code
This commit is contained in:
parent
2fe21231fc
commit
b9e853dbdb
1 changed files with 3 additions and 11 deletions
|
|
@ -45,20 +45,12 @@ It will load existing data from the configured
|
|||
directory, and start listening client connections
|
||||
on the configured port.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// TODO this code is duplicated from server/server.go:Server.Run() because it hasnt run yet
|
||||
var logOutput io.Writer
|
||||
if Server.Config.LogPath == "" {
|
||||
logOutput = stderr
|
||||
} else {
|
||||
var err error
|
||||
logOutput, err = os.OpenFile(Server.Config.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logOutput, err := server.GetLogWriter(Server.Config.LogPath, stderr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger := log.New(logOutput, "", log.LstdFlags)
|
||||
logger.Printf("Pilosa %s, build time %s\n", pilosa.Version, pilosa.BuildTime)
|
||||
// fmt.Fprintf(Server.Stderr, "Pilosa %s, build time %s\n", pilosa.Version, pilosa.BuildTime)
|
||||
|
||||
// Start CPU profiling.
|
||||
if Server.CPUProfile != "" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue