Skip to content

Commit

Permalink
Output log text fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Feb 10, 2023
1 parent e2d840f commit 383061c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cmd/aem/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func (c *CLI) configure() {
func (c *CLI) configureOutput() {
c.outputValue = c.config.Values().Output.Value
c.outputFormat = strings.ReplaceAll(c.config.Values().Output.Format, "yaml", "yml")
c.outputLogFile = c.config.Values().Output.LogFile
c.outputLogText = c.config.Values().Output.LogText
c.outputLogFile = c.config.Values().Output.Log.File
c.outputLogText = c.config.Values().Output.Log.Text

if len(c.outputValue) > 0 {
if c.outputValue != common.OutputValueNone && c.outputValue != common.OutputValueAll {
c.outputFormat = fmtx.Text
c.outputLogText = true
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/aem/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ func (c *CLI) rootFlags(cmd *cobra.Command) {
cmd.PersistentFlags().StringVar(&(c.config.Values().Output.Format),
"output-format", c.config.Values().Output.Format,
"Controls output format ("+strings.Join(cfg.OutputFormats(), "|")+")")
cmd.PersistentFlags().StringVar(&(c.config.Values().Output.LogFile),
"output-log-file", c.config.Values().Output.LogFile,
cmd.PersistentFlags().StringVar(&(c.config.Values().Output.Log.File),
"output-log-file", c.config.Values().Output.Log.File,
"Controls output file path")
cmd.PersistentFlags().BoolVar(&(c.config.Values().Output.Log.Text),
"output-log-text", c.config.Values().Output.Log.Text,
"Write outputs and log entries to file instead of printing to console (when output format is \"text\")")
cmd.PersistentFlags().StringVar(&(c.config.Values().Output.Value),
"output-value", c.config.Values().Output.Value,
"Limits output to single variable")
Expand Down
4 changes: 2 additions & 2 deletions pkg/cfg/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func setDefaults(v *viper.Viper) {
v.SetDefault("input.format", fmtx.YML)
v.SetDefault("input.file", common.STDIn)
v.SetDefault("output.format", fmtx.Text)
v.SetDefault("output.log_file", common.LogFile)
v.SetDefault("output.log_text", true)
v.SetDefault("output.value", common.OutputValueAll)
v.SetDefault("output.log.file", common.LogFile)
v.SetDefault("output.log.text", false)

v.SetDefault("instance.processing_mode", instance.ProcessingAuto)

Expand Down
10 changes: 6 additions & 4 deletions pkg/cfg/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ type ConfigValues struct {
} `mapstructure:"input" yaml:"input"`

Output struct {
LogFile string `mapstructure:"log_file" yaml:"log_file"`
LogText bool `mapstructure:"log_text" yaml:"log_text"`
Format string `mapstructure:"format" yaml:"format"`
Value string `mapstructure:"value" yaml:"value"`
Format string `mapstructure:"format" yaml:"format"`
Value string `mapstructure:"value" yaml:"value"`
Log struct {
File string `mapstructure:"file" yaml:"file"`
Text bool `mapstructure:"text" yaml:"text"`
} `mapstructure:"log" yaml:"log"`
} `mapstructure:"output" yaml:"output"`

App struct {
Expand Down
6 changes: 5 additions & 1 deletion project/classic/aem/default/etc/aem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,8 @@ input:

output:
format: text
file: aem/home/var/log/aem.log
log:
# File path of logs written especially when output format is different than 'text'
file: aem/home/var/log/aem.log
# Controls if console output and log entries should be written to file instead of printed to console when output format is 'text'
text: false
6 changes: 5 additions & 1 deletion project/cloud/aem/default/etc/aem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,8 @@ input:

output:
format: text
file: aem/home/var/log/aem.log
log:
# File path of logs written especially when output format is different than 'text'
file: aem/home/var/log/aem.log
# Controls if console output and log entries should be printed to console when output format is 'text'
text: false

0 comments on commit 383061c

Please sign in to comment.