Skip to content

Commit

Permalink
Merge pull request #236 from joereuss12/make-log-level-part-of-config…
Browse files Browse the repository at this point in the history
…-branch

Make default log level part of pelican config
  • Loading branch information
bbockelm authored Oct 25, 2023
2 parents e86ba50 + aa03af4 commit 74eb698
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ func main() {
}

func handleCLI(args []string) error {
exec_name := filepath.Base(args[0])
execName := filepath.Base(args[0])
// Take care of our Windows users
exec_name = strings.TrimSuffix(exec_name, ".exe")
execName = strings.TrimSuffix(execName, ".exe")
// Being case-insensitive
exec_name = strings.ToLower(exec_name)
execName = strings.ToLower(execName)

if exec_name == "stash_plugin" || exec_name == "osdf_plugin" || exec_name == "pelican_xfer_plugin" {
if execName == "stash_plugin" || execName == "osdf_plugin" || execName == "pelican_xfer_plugin" {
stashPluginMain(args[1:])
} else if exec_name == "stashcp" {
} else if execName == "stashcp" {
err := copyCmd.Execute()
if err != nil {
return err
Expand Down
7 changes: 6 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ func InitConfig() {
if param.Debug.GetBool() {
SetLogging(log.DebugLevel)
} else {
SetLogging(log.ErrorLevel)
logLevel := param.Logging_Level.GetString()
level, err := log.ParseLevel(logLevel)
if err != nil {
cobra.CheckErr(err)
}
SetLogging(level)
}
}

Expand Down
3 changes: 2 additions & 1 deletion config/resources/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#

Debug: false

Logging:
Level: "Error"
Server:
Port: 8444
Address: "0.0.0.0"
Expand Down
11 changes: 11 additions & 0 deletions docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ default: 10s
components: ["client", "nsregistry", "origin"]
---

############################
# Log-Level Configs #
############################
name: Logging.Level
description: >-
A string defining the log level of the client. Options include (going from most info to least): Trace, Debug, Info, Warn, Error, Fatal, Panic.
type: string
default: Error
components: ["*"]
---

############################
# Federation-Level Configs #
############################
Expand Down

0 comments on commit 74eb698

Please sign in to comment.