mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-04-01 18:15:54 +02:00
Remove dedicated fatal loglevel, change to Fprintln for unformatted
This commit is contained in:
parent
0191bc3821
commit
d209547968
@ -12,7 +12,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func cliInit() {
|
func cliInit() {
|
||||||
flag.BoolVar(&flagInit, "init", false, "Setup var directory, initialize swlite database file, config.json and .env")
|
flag.BoolVar(&flagInit, "init", false, "Setup var directory, initialize sqlite database file, config.json and .env")
|
||||||
flag.BoolVar(&flagReinitDB, "init-db", false, "Go through job-archive and re-initialize the 'job', 'tag', and 'jobtag' tables (all running jobs will be lost!)")
|
flag.BoolVar(&flagReinitDB, "init-db", false, "Go through job-archive and re-initialize the 'job', 'tag', and 'jobtag' tables (all running jobs will be lost!)")
|
||||||
flag.BoolVar(&flagSyncLDAP, "sync-ldap", false, "Sync the 'hpc_user' table with ldap")
|
flag.BoolVar(&flagSyncLDAP, "sync-ldap", false, "Sync the 'hpc_user' table with ldap")
|
||||||
flag.BoolVar(&flagServer, "server", false, "Start a server, continues listening on port after initialization and argument handling")
|
flag.BoolVar(&flagServer, "server", false, "Start a server, continues listening on port after initialization and argument handling")
|
||||||
@ -24,10 +24,10 @@ func cliInit() {
|
|||||||
flag.BoolVar(&flagForceDB, "force-db", false, "Force database version, clear dirty flag and exit")
|
flag.BoolVar(&flagForceDB, "force-db", false, "Force database version, clear dirty flag and exit")
|
||||||
flag.BoolVar(&flagLogDateTime, "logdate", false, "Set this flag to add date and time to log messages")
|
flag.BoolVar(&flagLogDateTime, "logdate", false, "Set this flag to add date and time to log messages")
|
||||||
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
|
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
|
||||||
flag.StringVar(&flagNewUser, "add-user", "", "Add a new user. Argument format: `<username>:[admin,support,manager,api,user]:<password>`")
|
flag.StringVar(&flagNewUser, "add-user", "", "Add a new user. Argument format: <username>:[admin,support,manager,api,user]:<password>")
|
||||||
flag.StringVar(&flagDelUser, "del-user", "", "Remove user by `username`")
|
flag.StringVar(&flagDelUser, "del-user", "", "Remove a existing user. Argument format: <username>")
|
||||||
flag.StringVar(&flagGenJWT, "jwt", "", "Generate and print a JWT for the user specified by its `username`")
|
flag.StringVar(&flagGenJWT, "jwt", "", "Generate and print a JWT for the user specified by its `username`")
|
||||||
flag.StringVar(&flagImportJob, "import-job", "", "Import a job. Argument format: `<path-to-meta.json>:<path-to-data.json>,...`")
|
flag.StringVar(&flagImportJob, "import-job", "", "Import a job. Argument format: `<path-to-meta.json>:<path-to-data.json>,...`")
|
||||||
flag.StringVar(&flagLogLevel, "loglevel", "warn", "Sets the logging level: `[debug,info,warn (default),err,fatal,crit]`")
|
flag.StringVar(&flagLogLevel, "loglevel", "warn", "Sets the logging level: `[debug, info (default), warn, err, crit]`")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,12 @@ var loglevel string = "info"
|
|||||||
/* CONFIG */
|
/* CONFIG */
|
||||||
|
|
||||||
func Init(lvl string, logdate bool) {
|
func Init(lvl string, logdate bool) {
|
||||||
|
// Discard I/O for all writers below selected loglevel; <CRITICAL> is always written.
|
||||||
switch lvl {
|
switch lvl {
|
||||||
case "crit":
|
case "crit":
|
||||||
ErrWriter = io.Discard
|
ErrWriter = io.Discard
|
||||||
fallthrough
|
fallthrough
|
||||||
case "err", "fatal":
|
case "err":
|
||||||
WarnWriter = io.Discard
|
WarnWriter = io.Discard
|
||||||
fallthrough
|
fallthrough
|
||||||
case "warn":
|
case "warn":
|
||||||
@ -63,8 +63,7 @@ func Init(lvl string, logdate bool) {
|
|||||||
// Nothing to do...
|
// Nothing to do...
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
fmt.Printf("pkg/log: Flag 'loglevel' has invalid value %#v\npkg/log: Will use default loglevel 'debug'\n", lvl)
|
fmt.Printf("pkg/log: Flag 'loglevel' has invalid value %#v\npkg/log: Will use default loglevel '%s'\n", lvl, loglevel)
|
||||||
//SetLogLevel("debug")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !logdate {
|
if !logdate {
|
||||||
@ -107,20 +106,20 @@ func printfStr(format string, v ...interface{}) string {
|
|||||||
// Prints to STDOUT without string formatting; application continues.
|
// Prints to STDOUT without string formatting; application continues.
|
||||||
// Used for special cases not requiring log information like date or location.
|
// Used for special cases not requiring log information like date or location.
|
||||||
func Print(v ...interface{}) {
|
func Print(v ...interface{}) {
|
||||||
fmt.Fprint(os.Stdout, v...)
|
fmt.Fprintln(os.Stdout, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints to STDOUT without string formatting; application exits with error code 0.
|
// Prints to STDOUT without string formatting; application exits with error code 0.
|
||||||
// Used for exiting succesfully with message after expected outcome, e.g. successful single-call application runs.
|
// Used for exiting succesfully with message after expected outcome, e.g. successful single-call application runs.
|
||||||
func Exit(v ...interface{}) {
|
func Exit(v ...interface{}) {
|
||||||
fmt.Fprint(os.Stdout, v...)
|
fmt.Fprintln(os.Stdout, v...)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints to STDOUT without string formatting; application exits with error code 1.
|
// Prints to STDOUT without string formatting; application exits with error code 1.
|
||||||
// Used for terminating with message after to be expected errors, e.g. wrong arguments or during init().
|
// Used for terminating with message after to be expected errors, e.g. wrong arguments or during init().
|
||||||
func Abort(v ...interface{}) {
|
func Abort(v ...interface{}) {
|
||||||
fmt.Fprint(os.Stdout, v...)
|
fmt.Fprintln(os.Stdout, v...)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user