mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2026-01-12 00:26:26 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bca0ceaf4 | ||
|
|
c2a6220fde |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -103,3 +103,4 @@ fabric.properties
|
|||||||
|
|
||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
*__debug_bin*
|
||||||
|
|||||||
29
.vscode/launch.json
vendored
29
.vscode/launch.json
vendored
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
// Use IntelliSense to learn about possible attributes.
|
// Use IntelliSense to learn about possible attributes.
|
||||||
// Hover to view descriptions of existing attributes.
|
// Hover to view descriptions of existing attributes.
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
{
|
"name": "Optimize Testdata",
|
||||||
"name": "Launch Package",
|
"type": "go",
|
||||||
"type": "go",
|
"request": "launch",
|
||||||
"request": "launch",
|
"mode": "auto",
|
||||||
"mode": "auto",
|
"program": "${workspaceFolder}/cmd/cbzoptimizer",
|
||||||
"program": "${fileDirname}"
|
"args": ["optimize", "${workspaceFolder}/testdata", "-l", "debug"],
|
||||||
}
|
"cwd": "${workspaceFolder}"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -54,14 +54,30 @@ func init() {
|
|||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
// Add log level flag (accepts zerolog levels: panic, fatal, error, warn, info, debug, trace)
|
// Add log level flag (accepts zerolog levels: panic, fatal, error, warn, info, debug, trace)
|
||||||
|
ef := enumflag.New(&logLevel, "log", LogLevelIds, enumflag.EnumCaseInsensitive)
|
||||||
rootCmd.PersistentFlags().VarP(
|
rootCmd.PersistentFlags().VarP(
|
||||||
enumflag.New(&logLevel, "log", LogLevelIds, enumflag.EnumCaseInsensitive),
|
ef,
|
||||||
"log", "l",
|
"log", "l",
|
||||||
"Set log level; can be 'panic', 'fatal', 'error', 'warn', 'info', 'debug', or 'trace'")
|
"Set log level; can be 'panic', 'fatal', 'error', 'warn', 'info', 'debug', or 'trace'")
|
||||||
|
ef.RegisterCompletion(rootCmd, "log", enumflag.Help[zerolog.Level]{
|
||||||
|
zerolog.PanicLevel: "Only log panic messages",
|
||||||
|
zerolog.FatalLevel: "Log fatal and panic messages",
|
||||||
|
zerolog.ErrorLevel: "Log error, fatal, and panic messages",
|
||||||
|
zerolog.WarnLevel: "Log warn, error, fatal, and panic messages",
|
||||||
|
zerolog.InfoLevel: "Log info, warn, error, fatal, and panic messages",
|
||||||
|
zerolog.DebugLevel: "Log debug, info, warn, error, fatal, and panic messages",
|
||||||
|
zerolog.TraceLevel: "Log all messages including trace",
|
||||||
|
})
|
||||||
|
|
||||||
// Add log level environment variable support
|
// Add log level environment variable support
|
||||||
viper.SetEnvPrefix("")
|
viper.BindEnv("log", "LOG_LEVEL")
|
||||||
viper.BindEnv("LOG_LEVEL")
|
viper.BindPFlag("log", rootCmd.PersistentFlags().Lookup("log"))
|
||||||
|
|
||||||
|
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
|
||||||
|
ConfigureLogging()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the configuration directory exists
|
||||||
|
|
||||||
err := os.MkdirAll(configFolder, os.ModePerm)
|
err := os.MkdirAll(configFolder, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -95,7 +111,7 @@ func ConfigureLogging() {
|
|||||||
level := zerolog.InfoLevel
|
level := zerolog.InfoLevel
|
||||||
|
|
||||||
// Check LOG_LEVEL environment variable first
|
// Check LOG_LEVEL environment variable first
|
||||||
envLogLevel := viper.GetString("LOG_LEVEL")
|
envLogLevel := viper.GetString("log")
|
||||||
if envLogLevel != "" {
|
if envLogLevel != "" {
|
||||||
if parsedLevel, err := zerolog.ParseLevel(envLogLevel); err == nil {
|
if parsedLevel, err := zerolog.ParseLevel(envLogLevel); err == nil {
|
||||||
level = parsedLevel
|
level = parsedLevel
|
||||||
|
|||||||
@@ -13,8 +13,5 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
commands.SetVersionInfo(version, commit, date)
|
commands.SetVersionInfo(version, commit, date)
|
||||||
|
|
||||||
// Configure logging before executing commands
|
|
||||||
commands.ConfigureLogging()
|
|
||||||
|
|
||||||
commands.Execute()
|
commands.Execute()
|
||||||
}
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -2,8 +2,6 @@ module github.com/belphemur/CBZOptimizer/v2
|
|||||||
|
|
||||||
go 1.25
|
go 1.25
|
||||||
|
|
||||||
toolchain go1.25.0
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
|
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
|
||||||
github.com/belphemur/go-webpbin/v2 v2.0.0
|
github.com/belphemur/go-webpbin/v2 v2.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user