mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:25:56 -04:00
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
|
## Enables colors in logs. Useful for debugging purposes
|
||||||
## This is overridden if "-k" or "--colorize"
|
## This is overridden if "-k" or "--colorize"
|
||||||
## are passed on the command line.
|
## 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
|
## Accepted values: true, false
|
||||||
## Default: false
|
## Default: true
|
||||||
##
|
##
|
||||||
#colorize_logs: false
|
#colorize_logs: true
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Features
|
# Features
|
||||||
|
@ -69,7 +69,7 @@ class Config
|
|||||||
# Default log level, valid YAML values are ints and strings, see src/invidious/helpers/logger.cr
|
# Default log level, valid YAML values are ints and strings, see src/invidious/helpers/logger.cr
|
||||||
property log_level : LogLevel = LogLevel::Info
|
property log_level : LogLevel = LogLevel::Info
|
||||||
# Enables colors in logs. Useful for debugging purposes
|
# 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)
|
# Database configuration with separate parameters (username, hostname, etc)
|
||||||
property db : DBConfig? = nil
|
property db : DBConfig? = nil
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ enum LogLevel
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Invidious::LogHandler < Kemal::BaseLogHandler
|
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
|
end
|
||||||
|
|
||||||
def call(context : HTTP::Server::Context)
|
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) %}
|
{% for level in %w(trace debug info warn error fatal) %}
|
||||||
def {{level.id}}(message : String)
|
def {{level.id}}(message : String)
|
||||||
if LogLevel::{{level.id.capitalize}} >= @level
|
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
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
Loading…
Reference in New Issue
Block a user