add logging clolr flag and change default values
All checks were successful
ci/woodpecker/push/docker-deploy Pipeline was successful
ci/woodpecker/pr/docker-deploy Pipeline was successful

This commit is contained in:
Adora Laura Kalb 2024-11-06 11:16:12 +01:00
parent 5d58ae8411
commit f575e0cb46
Signed by: adoralaura
SSH key fingerprint: SHA256:3XrkbR8ikAZJVtYfaUliX1MhmJYVAe/ocIb/MiDHBJ8
4 changed files with 35 additions and 17 deletions

View file

@ -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
@ -68,4 +74,4 @@ instead of immediately posting one bundle
[v0.2.0]: https://git.lauka.net/lauralani/humble-bot/compare/v0.1.2...v0.2.0
[v0.1.2]: https://git.lauka.net/lauralani/humble-bot/compare/v0.1.1...v0.1.2
[v0.1.1]: https://git.lauka.net/lauralani/humble-bot/compare/v0.1.0...v0.1.1
[v0.1.0]: https://git.lauka.net/lauralani/humble-bot/releases/tag/v0.1.0
[v0.1.0]: https://git.lauka.net/lauralani/humble-bot/releases/tag/v0.1.0

View file

@ -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())

View file

@ -3,32 +3,38 @@ 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
pollinterval: "30m"
pollinterval: "30m"

View file

@ -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"}})
}