mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 08:42:08 +05:30
Logger: Make colorize_logs true by default
This commit is contained in:
parent
f8ec312328
commit
d77afdcf00
@ -226,11 +226,13 @@ https_only: false
|
||||
## Enables colors in logs. Useful for debugging purposes
|
||||
## This is overridden if "-k" or "--colorize"
|
||||
## are passed on the command line.
|
||||
## Colors are also disabled if the environment variable
|
||||
## NO_COLOR is present and has any value
|
||||
##
|
||||
## Accepted values: true, false
|
||||
## Default: false
|
||||
## Default: true
|
||||
##
|
||||
#colorize_logs: false
|
||||
#colorize_logs: true
|
||||
|
||||
# -----------------------------
|
||||
# Features
|
||||
|
@ -69,7 +69,7 @@ class Config
|
||||
# Default log level, valid YAML values are ints and strings, see src/invidious/helpers/logger.cr
|
||||
property log_level : LogLevel = LogLevel::Info
|
||||
# Enables colors in logs. Useful for debugging purposes
|
||||
property colorize_logs : Bool = false
|
||||
property colorize_logs : Bool = true
|
||||
# Database configuration with separate parameters (username, hostname, etc)
|
||||
property db : DBConfig? = nil
|
||||
|
||||
|
@ -12,7 +12,7 @@ enum LogLevel
|
||||
end
|
||||
|
||||
class Invidious::LogHandler < Kemal::BaseLogHandler
|
||||
def initialize(@io : IO = STDOUT, @level = LogLevel::Debug, @color : Bool = true)
|
||||
def initialize(@io : IO = STDOUT, @level = LogLevel::Debug, @use_color : Bool = true)
|
||||
end
|
||||
|
||||
def call(context : HTTP::Server::Context)
|
||||
@ -56,8 +56,7 @@ class Invidious::LogHandler < Kemal::BaseLogHandler
|
||||
{% for level in %w(trace debug info warn error fatal) %}
|
||||
def {{level.id}}(message : String)
|
||||
if LogLevel::{{level.id.capitalize}} >= @level
|
||||
puts("#{Time.utc} [{{level.id}}] #{message}".colorize(color(LogLevel::{{level.id.capitalize}})).toggle(@color))
|
||||
|
||||
puts("#{Time.utc} [{{level.id}}] #{message}".colorize(color(LogLevel::{{level.id.capitalize}})).toggle(@use_color))
|
||||
end
|
||||
end
|
||||
{% end %}
|
||||
|
Loading…
Reference in New Issue
Block a user