add logging color flag and change default values #1
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 `list` alias to `queue show`
|
||||
- Added `delete` alias to `queue remove`
|
||||
- config option to toggle colored output
|
||||
- Docker build for armv7, arm64 and amd64
|
||||
|
||||
### Changed
|
||||
- Changed table output style
|
||||
- various default config values (see examples/config.yaml)
|
||||
|
||||
### Fixed
|
||||
- missing error handling
|
||||
|
||||
## [v0.2.1] - 2023-06-11
|
||||
### Changed
|
||||
|
|
10
cmd/root.go
10
cmd/root.go
|
@ -7,12 +7,13 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
log2 "log"
|
||||
"os"
|
||||
|
||||
"codeberg.org/lauralani/humble-bot/constants"
|
||||
"codeberg.org/lauralani/humble-bot/db"
|
||||
"codeberg.org/lauralani/humble-bot/log"
|
||||
"codeberg.org/lauralani/humble-bot/misc"
|
||||
log2 "log"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -62,9 +63,10 @@ func initConfig() {
|
|||
viper.SetConfigName("config")
|
||||
}
|
||||
|
||||
viper.SetDefault("mastodon.postinterval", "5m")
|
||||
viper.SetDefault("mastodon.visibility", "public")
|
||||
viper.SetDefault("mastodon.postinterval", "1h")
|
||||
viper.SetDefault("mastodon.visibility", "private")
|
||||
viper.SetDefault("humblebundle.pollinterval", "30m")
|
||||
viper.SetDefault("logging.colored_output", false)
|
||||
|
||||
if err := viper.ReadInConfig(); err == nil {
|
||||
log2.Printf("Starting humble-bot %v with config file: %v\n", constants.AppVersion, viper.ConfigFileUsed())
|
||||
|
|
|
@ -3,31 +3,37 @@ database:
|
|||
# PostgreSQL Database-URL
|
||||
# Format: postgresql://<user>:<password>@<host>/<database>
|
||||
# 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:
|
||||
# URL of your Mastodon Instance
|
||||
# Format: https://mastodon.social (without trailing slash)
|
||||
url: "https://"
|
||||
url: "https:///mastodon.social"
|
||||
|
||||
# Access token for your mastodon account
|
||||
# see $your_mastodon_url/settings/applications
|
||||
token: ""
|
||||
token: "a-secret-token"
|
||||
|
||||
# Interval in which humble-bot tries to post bundles
|
||||
# format: "20s" or "15m" or "1h"
|
||||
# default: 5m
|
||||
postinterval: "5m"
|
||||
# default: 1h
|
||||
postinterval: "1h"
|
||||
|
||||
# Post visibility of the bundles on mastodon
|
||||
# allowed values: ["public", "unlisted", "private"]
|
||||
# default: public
|
||||
visibility: "public"
|
||||
# default: private
|
||||
visibility: "private"
|
||||
|
||||
# Humble Bot logging settings
|
||||
logging:
|
||||
# enable colored logging
|
||||
# default: false
|
||||
colored_output: false
|
||||
|
||||
# Humble Bundle settings
|
||||
humblebundle:
|
||||
|
||||
# Interval in which humble-bot tries to query humblebundle.com
|
||||
# format: "20s" or "15m" or "1h"
|
||||
# default: 30m
|
||||
|
|
|
@ -7,18 +7,22 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var FlagDebug bool
|
||||
|
||||
func InitializeLogger() {
|
||||
_noColor := !viper.GetBool("logging.colored_output")
|
||||
|
||||
if os.Getenv("INVOCATION_ID") == "" {
|
||||
// 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 {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, NoColor: true, PartsExclude: []string{"time"}})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue