Browse Source

basic_formatter

main
pvincent 1 year ago
parent
commit
2700f3938b
  1. 4
      Gemfile
  2. 9
      Gemfile.lock
  3. 7
      README.md
  4. 29
      config/application.rb
  5. 15
      lib/formatters/basic_formatter.rb

4
Gemfile

@ -42,6 +42,10 @@ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
# Semantic logger for colorized output logging
gem "amazing_print"
gem "rails_semantic_logger"
# Use Sass to process CSS
# gem "sassc-rails"

9
Gemfile.lock

@ -68,6 +68,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
amazing_print (1.5.0)
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
@ -153,6 +154,10 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
rails_semantic_logger (4.12.0)
rack
railties (>= 5.1)
semantic_logger (~> 4.13)
railties (7.0.5)
actionpack (= 7.0.5)
activesupport (= 7.0.5)
@ -170,6 +175,8 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_logger (4.13.0)
concurrent-ruby (~> 1.0)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
@ -209,6 +216,7 @@ PLATFORMS
x86_64-linux
DEPENDENCIES
amazing_print
bootsnap
capybara
debug
@ -216,6 +224,7 @@ DEPENDENCIES
jbuilder
puma (~> 5.0)
rails (~> 7.0.4, >= 7.0.4.3)
rails_semantic_logger
selenium-webdriver
sprockets-rails
sqlite3 (~> 1.4)

7
README.md

@ -2,6 +2,7 @@
## Featuring
* LXD aware (through remote ssh)
* Rails version 7
* Markdown ready
* [x] Rails version 7
* [x] LXD aware (through remote ssh)
* [x] Rufo Formatter
* [ ] Semantic Logging

29
config/application.rb

@ -6,18 +6,23 @@ require "rails/all"
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Blog
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.rails_semantic_logger.semantic = false
config.rails_semantic_logger.started = false
config.rails_semantic_logger.processing = true
config.rails_semantic_logger.rendered = true
end
config.semantic_logger.backtrace_level = :info
config.rails_semantic_logger.ap_options = { multiline: true }
config.colorize_logging = false
config.rails_semantic_logger.console_logger = false
$stdout.sync = true
config.rails_semantic_logger.add_file_appender = false
require_relative "../lib/formatters/basic_formatter"
config.semantic_logger.add_appender(io: $stdout, formatter: BasicFormatter.new)
end

15
lib/formatters/basic_formatter.rb

@ -0,0 +1,15 @@
# My Custom colorized formatter
class BasicFormatter < SemanticLogger::Formatters::Color
ANSI_REVERSED_ERROR = "\e[1m\e[7m\e[91m".freeze
# Return the complete log level name in uppercase
def initialize
# super(ap: { multiline: true },
# time_format: "%H:%M:%S",
# color_map: {
# info: SemanticLogger::AnsiColors::RED,
# warn: SemanticLogger::AnsiColors::YELLOW,
# })
super(time_format: "%H:%M:%S", color_map: ColorMap.new(info: SemanticLogger::AnsiColors::RED, warn: SemanticLogger::AnsiColors::YELLOW))
end
end
Loading…
Cancel
Save