add logging clolr flag and change default values
This commit is contained in:
parent
5d58ae8411
commit
f575e0cb46
4 changed files with 35 additions and 17 deletions
|
@ -9,9 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
- Added `list` alias to `queue show`
|
- Added `list` alias to `queue show`
|
||||||
- Added `delete` alias to `queue remove`
|
- Added `delete` alias to `queue remove`
|
||||||
|
- config option to toggle colored output
|
||||||
|
- Docker build for armv7, arm64 and amd64
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Changed table output style
|
- Changed table output style
|
||||||
|
- various default config values (see examples/config.yaml)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- missing error handling
|
||||||
|
|
||||||
## [v0.2.1] - 2023-06-11
|
## [v0.2.1] - 2023-06-11
|
||||||
### Changed
|
### Changed
|
||||||
|
|
10
cmd/root.go
10
cmd/root.go
|
@ -7,12 +7,13 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
log2 "log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"codeberg.org/lauralani/humble-bot/constants"
|
"codeberg.org/lauralani/humble-bot/constants"
|
||||||
"codeberg.org/lauralani/humble-bot/db"
|
"codeberg.org/lauralani/humble-bot/db"
|
||||||
"codeberg.org/lauralani/humble-bot/log"
|
"codeberg.org/lauralani/humble-bot/log"
|
||||||
"codeberg.org/lauralani/humble-bot/misc"
|
"codeberg.org/lauralani/humble-bot/misc"
|
||||||
log2 "log"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -62,9 +63,10 @@ func initConfig() {
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.SetDefault("mastodon.postinterval", "5m")
|
viper.SetDefault("mastodon.postinterval", "1h")
|
||||||
viper.SetDefault("mastodon.visibility", "public")
|
viper.SetDefault("mastodon.visibility", "private")
|
||||||
viper.SetDefault("humblebundle.pollinterval", "30m")
|
viper.SetDefault("humblebundle.pollinterval", "30m")
|
||||||
|
viper.SetDefault("logging.colored_output", false)
|
||||||
|
|
||||||
if err := viper.ReadInConfig(); err == nil {
|
if err := viper.ReadInConfig(); err == nil {
|
||||||
log2.Printf("Starting humble-bot %v with config file: %v\n", constants.AppVersion, viper.ConfigFileUsed())
|
log2.Printf("Starting humble-bot %v with config file: %v\n", constants.AppVersion, viper.ConfigFileUsed())
|
||||||
|
|
|
@ -3,31 +3,37 @@ database:
|
||||||
# PostgreSQL Database-URL
|
# PostgreSQL Database-URL
|
||||||
# Format: postgresql://<user>:<password>@<host>/<database>
|
# Format: postgresql://<user>:<password>@<host>/<database>
|
||||||
# you can add optional postgres parameters after the database part, e.g. ?sslmode=verify-full
|
# you can add optional postgres parameters after the database part, e.g. ?sslmode=verify-full
|
||||||
url: "postgresql://<user>:<password>@<host>/<database>"
|
# see https://bun.uptrace.dev/postgres/#pgdriver for more database config options
|
||||||
|
url: "postgresql://humblebot:humblebot@db/humblebot?sslmode=disable"
|
||||||
|
|
||||||
# Mastodon Instance settings
|
# Mastodon Instance settings
|
||||||
mastodon:
|
mastodon:
|
||||||
# URL of your Mastodon Instance
|
# URL of your Mastodon Instance
|
||||||
# Format: https://mastodon.social (without trailing slash)
|
# Format: https://mastodon.social (without trailing slash)
|
||||||
url: "https://"
|
url: "https:///mastodon.social"
|
||||||
|
|
||||||
# Access token for your mastodon account
|
# Access token for your mastodon account
|
||||||
# see $your_mastodon_url/settings/applications
|
# see $your_mastodon_url/settings/applications
|
||||||
token: ""
|
token: "a-secret-token"
|
||||||
|
|
||||||
# Interval in which humble-bot tries to post bundles
|
# Interval in which humble-bot tries to post bundles
|
||||||
# format: "20s" or "15m" or "1h"
|
# format: "20s" or "15m" or "1h"
|
||||||
# default: 5m
|
# default: 1h
|
||||||
postinterval: "5m"
|
postinterval: "1h"
|
||||||
|
|
||||||
# Post visibility of the bundles on mastodon
|
# Post visibility of the bundles on mastodon
|
||||||
# allowed values: ["public", "unlisted", "private"]
|
# allowed values: ["public", "unlisted", "private"]
|
||||||
# default: public
|
# default: private
|
||||||
visibility: "public"
|
visibility: "private"
|
||||||
|
|
||||||
|
# Humble Bot logging settings
|
||||||
|
logging:
|
||||||
|
# enable colored logging
|
||||||
|
# default: false
|
||||||
|
colored_output: false
|
||||||
|
|
||||||
# Humble Bundle settings
|
# Humble Bundle settings
|
||||||
humblebundle:
|
humblebundle:
|
||||||
|
|
||||||
# Interval in which humble-bot tries to query humblebundle.com
|
# Interval in which humble-bot tries to query humblebundle.com
|
||||||
# format: "20s" or "15m" or "1h"
|
# format: "20s" or "15m" or "1h"
|
||||||
# default: 30m
|
# default: 30m
|
||||||
|
|
|
@ -7,18 +7,22 @@
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/rs/zerolog"
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var FlagDebug bool
|
var FlagDebug bool
|
||||||
|
|
||||||
func InitializeLogger() {
|
func InitializeLogger() {
|
||||||
|
_noColor := !viper.GetBool("logging.colored_output")
|
||||||
|
|
||||||
if os.Getenv("INVOCATION_ID") == "" {
|
if os.Getenv("INVOCATION_ID") == "" {
|
||||||
// detect systemd
|
// detect systemd
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, NoColor: _noColor, TimeFormat: time.RFC3339})
|
||||||
} else {
|
} else {
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, NoColor: true, PartsExclude: []string{"time"}})
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, NoColor: true, PartsExclude: []string{"time"}})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue