From 101131803342e818dcdfff0d506548b4292d6ced Mon Sep 17 00:00:00 2001 From: pvincent Date: Thu, 1 Jun 2023 23:23:51 +0400 Subject: [PATCH] no more 2 empty lines after rendering on logging --- app/views/layouts/_navbar.html.erb | 213 +++++++++++++++++++++++++ app/views/layouts/application.html.erb | 7 +- app/views/main/home.html.erb | 13 +- config/environments/development.rb | 9 +- lib/formatters/basic_formatter.rb | 8 +- 5 files changed, 231 insertions(+), 19 deletions(-) create mode 100644 app/views/layouts/_navbar.html.erb diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb new file mode 100644 index 0000000..eac6373 --- /dev/null +++ b/app/views/layouts/_navbar.html.erb @@ -0,0 +1,213 @@ + + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5f59981..7485d66 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,11 +10,8 @@ <%= javascript_importmap_tags %> - -
+ <%= render 'layouts/navbar' %> +
<%= yield %>
diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb index 98ac5c9..2fd6593 100644 --- a/app/views/main/home.html.erb +++ b/app/views/main/home.html.erb @@ -1,10 +1,9 @@
-
-

Main#index

-

Find me in app/views/main/index.html.erb

-
- this is index -
- pipipaaaa +

HOME

+

+ this is a welcome message +

+
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur provident dolor quod laboriosam facere quas, excepturi quasi consequuntur quo pariatur recusandae, eaque doloremque voluptas, a commodi officia ducimus animi incidunt.
diff --git a/config/environments/development.rb b/config/environments/development.rb index feb3e47..5aabc41 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -73,8 +73,13 @@ Rails.application.configure do io: $stdout, formatter: BasicFormatter.new, filter: ->log { - return true if log.name != "ActionView::Base" - log.message.exclude?("Rendered /") && log.message.exclude?("Rendered layout /") + if log.name == "ActionView::Base" + log.message&.exclude?("Rendered /") && log.message.exclude?("Rendered layout /") + elsif log.name == "Rails" && log.message != nil + log.message.exclude?("Started GET \"/rails/live/reload") + else + true + end }, ) end diff --git a/lib/formatters/basic_formatter.rb b/lib/formatters/basic_formatter.rb index 83bc020..c7eb7a5 100644 --- a/lib/formatters/basic_formatter.rb +++ b/lib/formatters/basic_formatter.rb @@ -26,11 +26,9 @@ class BasicFormatter < SemanticLogger::Formatters::Color case log.level when :info - message = if log.name == "Rails" && log.message.starts_with?("Started") - log.message.split("for")[0] - else - log.message - end + message = log.message + message = message&.rstrip if log.name == "Rails" && message.starts_with?("Completed") + message = message.split("for")[0] if log.name == "Rails" && message.starts_with?("Started") if log.name == "Rails" || log.name == "ActionView::Base" "#{prefix} #{ANSI_GRAY}#{message}#{color_map.clear}" else