mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-15 12:57:38 -04:00
Merge branch 'master' into feature/settings
This commit is contained in:
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,4 +1,27 @@
|
||||
# Changes in 0.1.0
|
||||
# Changelog for [0.1.1] (2020-04-29)
|
||||
|
||||
The following sections list the changes in ocis-accounts 0.1.1.
|
||||
|
||||
[0.1.1]: https://github.com/owncloud/ocis-accounts/compare/v0.1.0...v0.1.1
|
||||
|
||||
## Summary
|
||||
|
||||
* Enhancement - Logging is configurable: [#24](https://github.com/owncloud/ocis-accounts/pull/24)
|
||||
|
||||
## Details
|
||||
|
||||
* Enhancement - Logging is configurable: [#24](https://github.com/owncloud/ocis-accounts/pull/24)
|
||||
|
||||
ACCOUNTS_LOG_* env-vars or cli-flags can be used for logging configuration. See --help for
|
||||
more details.
|
||||
|
||||
https://github.com/owncloud/ocis-accounts/pull/24
|
||||
|
||||
# Changelog for [0.1.0] (2020-03-18)
|
||||
|
||||
The following sections list the changes in ocis-accounts 0.1.0.
|
||||
|
||||
[0.1.0]: https://github.com/owncloud/ocis-accounts/compare/500e303cb544ed93d84153f01219d77eeee44929...v0.1.0
|
||||
|
||||
## Summary
|
||||
|
||||
|
||||
5
changelog/0.1.1_2020-04-29/configurable-log.md
Normal file
5
changelog/0.1.1_2020-04-29/configurable-log.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Enhancement: Logging is configurable
|
||||
|
||||
ACCOUNTS_LOG_* env-vars or cli-flags can be used for logging configuration. See --help for more details.
|
||||
|
||||
https://github.com/owncloud/ocis-accounts/pull/24
|
||||
@@ -1,6 +1,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-accounts/pkg/flagset"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
@@ -24,25 +25,26 @@ var (
|
||||
|
||||
// Execute is the entry point for the ocis-accounts command.
|
||||
func Execute() error {
|
||||
rootCfg := config.New()
|
||||
app := &cli.App{
|
||||
Name: "ocis-accounts",
|
||||
Version: version.String,
|
||||
Usage: "Example service for Reva/oCIS",
|
||||
|
||||
Flags: flagset.RootWithConfig(rootCfg),
|
||||
Before: func(c *cli.Context) error {
|
||||
log := NewLogger(config.New())
|
||||
logger := NewLogger(config.New())
|
||||
for _, v := range defaultConfigPaths {
|
||||
// location is the user's home
|
||||
if v[0] == '$' || v[0] == '~' {
|
||||
usr, _ := user.Current()
|
||||
err := godotenv.Load(path.Join(usr.HomeDir, ".ocis", defaultFilename+".env"))
|
||||
if err != nil {
|
||||
log.Debug().Msgf("ignoring missing env file on dir: %v", v)
|
||||
logger.Debug().Msgf("ignoring missing env file on dir: %v", v)
|
||||
}
|
||||
} else {
|
||||
err := godotenv.Load(path.Join(v, defaultFilename+".env"))
|
||||
if err != nil {
|
||||
log.Debug().Msgf("ignoring missing env file on dir: %v", v)
|
||||
logger.Debug().Msgf("ignoring missing env file on dir: %v", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +59,7 @@ func Execute() error {
|
||||
},
|
||||
|
||||
Commands: []*cli.Command{
|
||||
Server(config.New()),
|
||||
Server(rootCfg),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -78,9 +80,9 @@ func Execute() error {
|
||||
func NewLogger(cfg *config.Config) log.Logger {
|
||||
return log.NewLogger(
|
||||
log.Name("accounts"),
|
||||
log.Level("info"),
|
||||
log.Pretty(true),
|
||||
log.Color(true),
|
||||
log.Level(cfg.Log.Level),
|
||||
log.Pretty(cfg.Log.Pretty),
|
||||
log.Color(cfg.Log.Color),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,19 @@ type Server struct {
|
||||
Address string
|
||||
}
|
||||
|
||||
// Log defines the available logging configuration.
|
||||
type Log struct {
|
||||
Level string
|
||||
Pretty bool
|
||||
Color bool
|
||||
}
|
||||
|
||||
// Config merges all Account config parameters.
|
||||
type Config struct {
|
||||
MountPath string
|
||||
Manager string
|
||||
Server Server
|
||||
Log Log
|
||||
}
|
||||
|
||||
// New returns a new config.
|
||||
|
||||
@@ -3,6 +3,33 @@ package flagset
|
||||
import "github.com/micro/cli/v2"
|
||||
import "github.com/owncloud/ocis-accounts/pkg/config"
|
||||
|
||||
// RootWithConfig applies cfg to the root flagset
|
||||
func RootWithConfig(cfg *config.Config) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "log-level",
|
||||
Value: "info",
|
||||
Usage: "Set logging level",
|
||||
EnvVars: []string{"ACCOUNTS_LOG_LEVEL"},
|
||||
Destination: &cfg.Log.Level,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "log-pretty",
|
||||
Usage: "Enable pretty logging",
|
||||
EnvVars: []string{"ACCOUNTS_LOG_PRETTY"},
|
||||
Destination: &cfg.Log.Pretty,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "log-color",
|
||||
Usage: "Enable colored logging",
|
||||
EnvVars: []string{"ACCOUNTS_LOG_COLOR"},
|
||||
Destination: &cfg.Log.Color,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ServerWithConfig applies cfg to the root flagset
|
||||
func ServerWithConfig(cfg *config.Config) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
|
||||
Reference in New Issue
Block a user