From 7d36d98d236777adc33e1dd14105a1af7a519be9 Mon Sep 17 00:00:00 2001 From: JV009 Date: Mon, 10 Feb 2025 11:00:12 +0300 Subject: [PATCH] Added logger --- app/controllers/tests_controller.rb | 4 ++- app/views/tests/index.html.erb | 2 +- app/views/tests/show.html.erb | 12 ++++++++ config.ru | 1 + config/environment.rb | 1 + config/routes.rb | 1 + db/test_guru.sqlite | Bin 12288 -> 12288 bytes lib/simpler/application.rb | 1 - lib/simpler/controller.rb | 27 ++++++++++++++--- lib/simpler/router.rb | 1 - lib/simpler/router/route.rb | 14 ++++++++- log/app.log | 18 ++++++++++++ middleware/simpler_logger.rb | 44 ++++++++++++++++++++++++++++ 13 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 app/views/tests/show.html.erb create mode 100644 log/app.log create mode 100644 middleware/simpler_logger.rb diff --git a/app/controllers/tests_controller.rb b/app/controllers/tests_controller.rb index 1526a689..8e5687e0 100644 --- a/app/controllers/tests_controller.rb +++ b/app/controllers/tests_controller.rb @@ -5,7 +5,9 @@ def index end def create - end + def show + @test = Test.find(id: params[:id]) + end end diff --git a/app/views/tests/index.html.erb b/app/views/tests/index.html.erb index 39fce580..0915cef4 100644 --- a/app/views/tests/index.html.erb +++ b/app/views/tests/index.html.erb @@ -9,4 +9,4 @@

<%= @time %>

- \ No newline at end of file + diff --git a/app/views/tests/show.html.erb b/app/views/tests/show.html.erb new file mode 100644 index 00000000..0e35f0af --- /dev/null +++ b/app/views/tests/show.html.erb @@ -0,0 +1,12 @@ + + + + + Show | Simpler application + + +

Simpler framework at work!

+ +

Test id: <%= @test_id %>

+ + diff --git a/config.ru b/config.ru index 3060cc20..f8c72a1c 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,4 @@ require_relative 'config/environment' +use SimplerLogger run Simpler.application diff --git a/config/environment.rb b/config/environment.rb index 7a0d38c3..28e320c8 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +1,4 @@ +require_relative '../middleware/simpler_logger' require_relative '../lib/simpler' Simpler.application.bootstrap! diff --git a/config/routes.rb b/config/routes.rb index 4a751251..1700ff3a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Simpler.application.routes do get '/tests', 'tests#index' post '/tests', 'tests#create' + get '/tests/:id', 'tests#show' end diff --git a/db/test_guru.sqlite b/db/test_guru.sqlite index 8624a03ab149d27f007f699649e9822c446f66e1..f8fa32e5d797bab83b2a0cee8fd46bf51d3ce5a7 100644 GIT binary patch delta 153 zcmZojXh@hK&B!%T##xYyL9eQimw|zSiC>6;KZRdtv!cKvzR5!TpTs!%LmBwr^55b= z!M~e-3I9a?I{qB~P@uduzrQFa3xhtVS7KRWaB@**L5YG>VsU12u>c1PgEC`KX;P(v xYehk7Q3;bEI}3w4Cs@QWr7SToIW