Skip to content
Snippets Groups Projects
Commit e9f82230 authored by Travis Ralston's avatar Travis Ralston
Browse files

Disable log colours by default

parent c564b971
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ...@@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased] ## [Unreleased]
### Changed
* Turned color-coded logs off by default. This can be changed in the config.
## [1.2.6] - March 25th, 2021 ## [1.2.6] - March 25th, 2021
### Added ### Added
......
...@@ -59,7 +59,7 @@ func main() { ...@@ -59,7 +59,7 @@ func main() {
assets.SetupTemplates(*templatesPath) assets.SetupTemplates(*templatesPath)
assets.SetupAssets(*assetsPath) assets.SetupAssets(*assetsPath)
err := logging.Setup(config.Get().General.LogDirectory) err := logging.Setup(config.Get().General.LogDirectory, config.Get().General.LogColors)
if err != nil { if err != nil {
panic(err) panic(err)
} }
......
...@@ -24,6 +24,7 @@ func NewDefaultMainConfig() MainRepoConfig { ...@@ -24,6 +24,7 @@ func NewDefaultMainConfig() MainRepoConfig {
BindAddress: "127.0.0.1", BindAddress: "127.0.0.1",
Port: 8000, Port: 8000,
LogDirectory: "logs", LogDirectory: "logs",
LogColors: false,
TrustAnyForward: false, TrustAnyForward: false,
UseForwardedHost: true, UseForwardedHost: true,
}, },
......
...@@ -4,6 +4,7 @@ type GeneralConfig struct { ...@@ -4,6 +4,7 @@ type GeneralConfig struct {
BindAddress string `yaml:"bindAddress"` BindAddress string `yaml:"bindAddress"`
Port int `yaml:"port"` Port int `yaml:"port"`
LogDirectory string `yaml:"logDirectory"` LogDirectory string `yaml:"logDirectory"`
LogColors bool `yaml:"logColors"`
TrustAnyForward bool `yaml:"trustAnyForwardedAddress"` TrustAnyForward bool `yaml:"trustAnyForwardedAddress"`
UseForwardedHost bool `yaml:"useForwardedHost"` UseForwardedHost bool `yaml:"useForwardedHost"`
} }
......
...@@ -19,13 +19,13 @@ func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) { ...@@ -19,13 +19,13 @@ func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) {
return f.Formatter.Format(entry) return f.Formatter.Format(entry)
} }
func Setup(dir string) error { func Setup(dir string, colors bool) error {
formatter := &utcFormatter{ formatter := &utcFormatter{
&logrus.TextFormatter{ &logrus.TextFormatter{
TimestampFormat: "2006-01-02 15:04:05.000 Z07:00", TimestampFormat: "2006-01-02 15:04:05.000 Z07:00",
FullTimestamp: true, FullTimestamp: true,
ForceColors: true, ForceColors: colors,
DisableColors: false, DisableColors: !colors,
DisableTimestamp: false, DisableTimestamp: false,
QuoteEmptyFields: true, QuoteEmptyFields: true,
}, },
......
...@@ -11,6 +11,10 @@ repo: ...@@ -11,6 +11,10 @@ repo:
# live reloaded. # live reloaded.
logDirectory: logs logDirectory: logs
# Set to true to enable color coding in your logs. Note that this may cause escape sequences to
# appear in logs which render them unreadable, which is why colors are disabled by default.
logColors: false
# If true, the media repo will accept any X-Forwarded-For header without validation. In most cases # If true, the media repo will accept any X-Forwarded-For header without validation. In most cases
# this option should be left as "false". Note that the media repo already expects an X-Forwarded-For # this option should be left as "false". Note that the media repo already expects an X-Forwarded-For
# header, but validates it to ensure the IP being given makes sense. # header, but validates it to ensure the IP being given makes sense.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment