diff --git a/Gemfile b/Gemfile index abff517..1a6dc18 100644 --- a/Gemfile +++ b/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" diff --git a/Gemfile.lock b/Gemfile.lock index 89852e4..04c97ee 100644 --- a/Gemfile.lock +++ b/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) diff --git a/README.md b/README.md index 4336209..6fecabc 100644 --- a/README.md +++ b/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 diff --git a/config/application.rb b/config/application.rb index abf93e9..b1603c5 100644 --- a/config/application.rb +++ b/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 diff --git a/lib/formatters/basic_formatter.rb b/lib/formatters/basic_formatter.rb new file mode 100644 index 0000000..264067f --- /dev/null +++ b/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