log_inspector 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +37 -0
  4. data/app/assets/javascripts/log_inspector/application.js +13 -0
  5. data/app/assets/javascripts/log_inspector/log_inspector.js +47 -0
  6. data/app/assets/stylesheets/log_inspector/application.css +14 -0
  7. data/app/assets/stylesheets/log_inspector/log_inspector.css +129 -0
  8. data/app/controllers/log_inspector/application_controller.rb +5 -0
  9. data/app/controllers/log_inspector/logs_controller.rb +35 -0
  10. data/app/helpers/log_inspector/application_helper.rb +4 -0
  11. data/app/helpers/log_inspector/logs_helper.rb +7 -0
  12. data/app/views/layouts/log_inspector/application.html.erb +25 -0
  13. data/app/views/log_inspector/logs/_file_contents.html.erb +25 -0
  14. data/app/views/log_inspector/logs/_folder_list.html.erb +20 -0
  15. data/app/views/log_inspector/logs/dir_contents.js.erb +4 -0
  16. data/app/views/log_inspector/logs/file_contents.js.erb +3 -0
  17. data/app/views/log_inspector/logs/index.html.erb +21 -0
  18. data/config/routes.rb +5 -0
  19. data/lib/log_inspector.rb +4 -0
  20. data/lib/log_inspector/engine.rb +5 -0
  21. data/lib/log_inspector/version.rb +3 -0
  22. data/lib/tasks/log_inspector_tasks.rake +4 -0
  23. data/test/dummy/README.rdoc +28 -0
  24. data/test/dummy/Rakefile +6 -0
  25. data/test/dummy/app/assets/javascripts/application.js +13 -0
  26. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  27. data/test/dummy/app/controllers/application_controller.rb +5 -0
  28. data/test/dummy/app/helpers/application_helper.rb +2 -0
  29. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  30. data/test/dummy/bin/bundle +3 -0
  31. data/test/dummy/bin/rails +4 -0
  32. data/test/dummy/bin/rake +4 -0
  33. data/test/dummy/bin/setup +29 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/config/application.rb +26 -0
  36. data/test/dummy/config/boot.rb +5 -0
  37. data/test/dummy/config/database.yml +25 -0
  38. data/test/dummy/config/environment.rb +5 -0
  39. data/test/dummy/config/environments/development.rb +41 -0
  40. data/test/dummy/config/environments/production.rb +79 -0
  41. data/test/dummy/config/environments/test.rb +42 -0
  42. data/test/dummy/config/initializers/assets.rb +11 -0
  43. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  45. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/test/dummy/config/initializers/inflections.rb +16 -0
  47. data/test/dummy/config/initializers/mime_types.rb +4 -0
  48. data/test/dummy/config/initializers/session_store.rb +3 -0
  49. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  50. data/test/dummy/config/locales/en.yml +23 -0
  51. data/test/dummy/config/routes.rb +4 -0
  52. data/test/dummy/config/secrets.yml +22 -0
  53. data/test/dummy/db/development.sqlite3 +0 -0
  54. data/test/dummy/log/development.log +130 -0
  55. data/test/dummy/public/404.html +67 -0
  56. data/test/dummy/public/422.html +67 -0
  57. data/test/dummy/public/500.html +66 -0
  58. data/test/dummy/public/favicon.ico +0 -0
  59. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0y/0yjx2i0nmZqwdLWslc0yDGRUhVGkv8ERUl84cw7dTkw.cache +1 -0
  60. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4y/4yMOi0MrbkUaXUC1UGYxdMTPEQgt2CPWNvi6e96uxaw.cache +0 -0
  61. data/test/dummy/tmp/cache/assets/sprockets/v3.0/52/52LcZUsZZiNPAUmhnfNk1z8dVt3PrCzZKsv9OTdokOk.cache +0 -0
  62. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6c/6cueXxOf_mR9xKpYenM5emAbqgE1i3KW4Y_cE8Dk2ps.cache +2 -0
  63. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6z/6zEHEYmN_KIEzK6_KAhvQDlkLzMnrdVoeJOP1TNufZA.cache +2 -0
  64. data/test/dummy/tmp/cache/assets/sprockets/v3.0/7q/7qDkYoxTbaURwA35XaukvRPR4LZqXTb7Tqf3zeCc1k4.cache +2 -0
  65. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9N/9NrbIEau0zua8QoLQ3XbPBdJmWdJPArwEldK7g71Ry4.cache +2 -0
  66. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9d/9d0IfaGcoT2cqOYryLTW-d2hWdkhJys5XS5_BsrCaiY.cache +0 -0
  67. data/test/dummy/tmp/cache/assets/sprockets/v3.0/BG/BGHSjISlgNIEhpLwjIOoZXLVLHEtOwBEJefvoFtKETs.cache +2 -0
  68. data/test/dummy/tmp/cache/assets/sprockets/v3.0/CC/CCXFxLzjxAzd7lZnlLU9d26oB5ohv26zFzbJk5nU-9Y.cache +2 -0
  69. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Cd/CdvY0rV5Fa-DezW9--_Rto5AEU7JBN-_F6x6ItgXOPo.cache +0 -0
  70. data/test/dummy/tmp/cache/assets/sprockets/v3.0/G7/G7QP2HuwtUd8D09prRQUp6Vyj8jbWL7TZYAtxkrNklk.cache +2 -0
  71. data/test/dummy/tmp/cache/assets/sprockets/v3.0/I0/I0j16VwEDAK0Jl6X-n1rswBBY_KLOhpwIJoAfETqgdw.cache +0 -0
  72. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Js/JsOpasUlDMF-NEsm-0XyvAGeWJHyGKMmwIuUDiNNFRY.cache +2 -0
  73. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ke/KeXx19PBjwB-uINDw9gnVBkUN9QkvDDeHrHCksryHQs.cache +1 -0
  74. data/test/dummy/tmp/cache/assets/sprockets/v3.0/L1/L1Y4b8ppqT2akZG6FnX-FWZ_m0mvNYrWiWnzMIizm10.cache +2 -0
  75. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OF/OFm7dNMop5t2fsf2_0bREAPn0k8Kmie7UEOqbYxaD_M.cache +2 -0
  76. data/test/dummy/tmp/cache/assets/sprockets/v3.0/QX/QX1mHY-mCgHmwmWxRkFTUVsJ5HKbyPpNnlVQGU_0HPQ.cache +1 -0
  77. data/test/dummy/tmp/cache/assets/sprockets/v3.0/RE/RE2jMVdk-GcWx49IkLXXHDBbgWnHxkNFfeMIDUMU4M4.cache +1 -0
  78. data/test/dummy/tmp/cache/assets/sprockets/v3.0/RP/RPFT8-jWNmJ51NqtyuiqkB6SDpJ44piuvgKnGgOyjdY.cache +2 -0
  79. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Rt/Rt243JzUgm2vop7gVdsaLk29lZfZUFXR89bgeFi6Bks.cache +1 -0
  80. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TK/TKfmevUUB0m67qHdyiqBMQq792W2hADaWbdtNmUQ8fE.cache +0 -0
  81. data/test/dummy/tmp/cache/assets/sprockets/v3.0/U4/U40pG4uRX_VT11S6jF0yjUdIHf744UswA6IupSVi5B0.cache +1 -0
  82. data/test/dummy/tmp/cache/assets/sprockets/v3.0/VJ/VJZf6loKqZz7jT1CRPQM9yXhqcDttEgHAi0IHYXCHJ4.cache +1 -0
  83. data/test/dummy/tmp/cache/assets/sprockets/v3.0/VO/VOn9z3AK4q4OOo5WxJvIqUXGoHcum2cSXHZyLDxTnA4.cache +1 -0
  84. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Yz/YzkhzcNL66EDHHEuTh_mqv6W-6IlRil60UYls40NnTI.cache +0 -0
  85. data/test/dummy/tmp/cache/assets/sprockets/v3.0/aN/aNhhF1a2vm9LZySZXuYFToWNcgeFpyUxb2yFzx5dQrI.cache +1 -0
  86. data/test/dummy/tmp/cache/assets/sprockets/v3.0/bv/bvznYaAD2Akrn6tRA7QbzHpPHIiJT5CYMPnuH3bQPbA.cache +1 -0
  87. data/test/dummy/tmp/cache/assets/sprockets/v3.0/d9/d9Cg_2YrFcbyaUhXRZTceMsS2kLjcpA_-9I7mi8TTWw.cache +1 -0
  88. data/test/dummy/tmp/cache/assets/sprockets/v3.0/eO/eOv1op0qmqHi1RyKoYldtvvcl2BMOEUCSo1OPkbCQoc.cache +1 -0
  89. data/test/dummy/tmp/cache/assets/sprockets/v3.0/eq/equ0NynE7_HWw9cdGuDnwiJXdnG_HXoTLngcsX1sS68.cache +0 -0
  90. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fQ/fQuCzO4oDlqru0-RE5PL0krTDvMg6i-02e4rAppEnyM.cache +1 -0
  91. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fa/faG0VWkwesZEu_09Rb3D5TQPCmXVihje_RLbHWYBI5s.cache +0 -0
  92. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fi/fijcQXgMohDZOZ4M728spwXiIsgV7hfBTIp839v1tts.cache +1 -0
  93. data/test/dummy/tmp/cache/assets/sprockets/v3.0/iZ/iZHr9dToVTGKD78bKiasiAKKIX3UsoylHVOH8fh2-08.cache +1 -0
  94. data/test/dummy/tmp/cache/assets/sprockets/v3.0/in/inKh_WM0NI8ZJbbYr1c-3iPf5ogyLOZ5V2gPMd7IdDw.cache +0 -0
  95. data/test/dummy/tmp/cache/assets/sprockets/v3.0/k3/k3uyFw5bLVCkWd1TN-G0l8XVjU24pz1NHQ0uE0tB0PE.cache +0 -0
  96. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m7/m7RyV2amu-MP_1uGjfAqIRFqaEvgKXEioQWf3OfNqdg.cache +2 -0
  97. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mW/mWotCpRhR80HB0c_Hvlx9sYhJ_aI-I06MNNgTXHL7qA.cache +1 -0
  98. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nX/nXvZe2dttgUKYR99mcZ_s69KYCMS2drWnb7fiU73HCg.cache +0 -0
  99. data/test/dummy/tmp/cache/assets/sprockets/v3.0/oL/oLKgG-GrQadF0aYtBjbRcmtG7p7-V44Eg8LuTqnkAW0.cache +1 -0
  100. data/test/dummy/tmp/cache/assets/sprockets/v3.0/oV/oVp94AATrZEXJENVhHW1yLDCNcl8nSia7GXyLdxO07g.cache +0 -0
  101. data/test/dummy/tmp/cache/assets/sprockets/v3.0/px/pxMa2MSSp1qRbvLIyRSk6hb3F5djJ8zP5WIX51OnDJg.cache +0 -0
  102. data/test/dummy/tmp/cache/assets/sprockets/v3.0/py/pyZ2Dd2uy3hSL4F1fa60y6X9hQVnBVxsgUc2Snh3sOc.cache +0 -0
  103. data/test/dummy/tmp/cache/assets/sprockets/v3.0/qa/qaXezH6QOMBvxNhYhSOj464igHPmLMObu7MVnPZDQzY.cache +1 -0
  104. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ts/tsEshchC2jWexOhgMhopUcqxFGKuEOII_M6RpWdi0B0.cache +1 -0
  105. data/test/dummy/tmp/cache/assets/sprockets/v3.0/uG/uGxnbi9_3oXzCbYkFYPJ7VWi-DIjiPw-2cPqluq3qos.cache +2 -0
  106. data/test/dummy/tmp/cache/assets/sprockets/v3.0/v8/v8yPBJtHK04q_s1O6KdlfMWBr6PPnFSb5LZgr_jGKeo.cache +1 -0
  107. data/test/dummy/tmp/cache/assets/sprockets/v3.0/vQ/vQyeu7nK0korPDY3FueOgohjPCIxuN-naaT175epN3g.cache +0 -0
  108. data/test/dummy/tmp/cache/assets/sprockets/v3.0/vV/vVD2lxq3cfeBu3afX9w019Id8mzwn9c-_oY7wOv1cA4.cache +1 -0
  109. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yI/yIfjc_jL6SU2G_uHLxC-Xq-i5PN48jENSR39nzNOMcI.cache +1 -0
  110. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zX/zXE7FdZFI1O7oOCvLIjR7DbGrfRdfZKoiZtN6QltYWk.cache +2 -0
  111. data/test/dummy/tmp/pids/server.pid +1 -0
  112. data/test/integration/navigation_test.rb +8 -0
  113. data/test/log_inspector_test.rb +7 -0
  114. data/test/test_helper.rb +21 -0
  115. metadata +277 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6e652eb0a6735c43d311d50b803c5a9390851f8
4
+ data.tar.gz: d7e7a9b1f1a208d16093b3e53116b57409de7ea1
5
+ SHA512:
6
+ metadata.gz: 9562da8658e57b3876b91ee50618009e181da951e20897a976b3f19754311cd33832d1654133964f48b63e537f22b55143538490c9c30a18c2e4807f7faf6f2a
7
+ data.tar.gz: b08a14b31e6dcdef800ae250804a311aa9d7577784349f4c5cf0d2e6cdcf32d6fb1f257e7427b201a5eff2a2ab2cd6201c6995b3c61cb44d0fa997ad3484ba3e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Sean Huber
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'LogInspector'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require log_inspector/log_inspector
@@ -0,0 +1,47 @@
1
+
2
+ function intializeLogInspector( dir_contents_url, file_contents_url, root_dir ) {
3
+ $(window).resize(function() {
4
+ $('.panel').height($(window).height() - $('.panel').position().top - 10); // 10px padding
5
+ });
6
+
7
+ $('body').css({ 'overflow-y': 'hidden' });
8
+ $(window).trigger('resize');
9
+
10
+ $.get(dir_contents_url, $.param({path: root_dir}));
11
+
12
+ $('.folder-list').on('click', 'li', function() {
13
+ $('.folder-list li').removeClass('selected');
14
+ $(this).addClass('selected');
15
+
16
+ if ( $(this).hasClass('file') ) {
17
+ getFileContents( $(this).data('full-path') );
18
+ }
19
+ return false;
20
+ });
21
+
22
+ function getFileContents( filepath ) {
23
+ $('.file-contents').addClass('throbbing');
24
+ $.get(file_contents_url, $.param({filepath: filepath}));
25
+ }
26
+
27
+ $('.folder-list').on('click', 'li.directory > .chevron', function() {
28
+ if ( $(this).hasClass('glyphicon-chevron-right') ) {
29
+ $(this).switchClass( 'glyphicon-chevron-right', 'glyphicon-chevron-down' );
30
+ var sub_list = $(this).siblings('ul');
31
+ sub_list.show();
32
+ if ( sub_list.hasClass('loading') ) {
33
+ $.get(dir_contents_url, $.param({path: $(this).parent().attr('data-full-path')}));
34
+ }
35
+ } else if ( $(this).hasClass('glyphicon-chevron-down') ) {
36
+ $(this).switchClass('glyphicon-chevron-down', 'glyphicon-chevron-right');
37
+ $(this).siblings('ul').hide();
38
+ }
39
+ return false;
40
+ });
41
+
42
+ $('.sh-log-panel.right').on('click', '.display-all-lines', function() {
43
+ $('.file-contents').addClass('throbbing');
44
+ $.get( $(this).attr('href') );
45
+ return false;
46
+ });
47
+ }
@@ -0,0 +1,14 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require log_inspector/log_inspector
14
+ */
@@ -0,0 +1,129 @@
1
+ html {
2
+ height: 100%;
3
+ width: 100%;
4
+ min-width: 100%;
5
+ min-height: 100%;
6
+ }
7
+
8
+ body {
9
+ height: 100%;
10
+ width: 100%;
11
+ padding: 0;
12
+ margin: 0;
13
+ background-color: #e2e2e2 !important;
14
+ background-repeat: repeat;
15
+ }
16
+
17
+ .sh-log-panel {
18
+ float: left;
19
+ width: 25%;
20
+ padding: 0 5px;
21
+ margin-top: 10px;
22
+ }
23
+
24
+ .sh-log-panel.right {
25
+ width: 75%;
26
+ }
27
+
28
+ .sh-log-panel > .panel {
29
+ overflow-y: auto;
30
+ }
31
+
32
+ .sh-log-panel ul.loading > li {
33
+ color: gray;
34
+ }
35
+
36
+ .sh-log-panel ul.folder-list {
37
+ padding-left: 5px;
38
+ }
39
+
40
+ .sh-log-panel ul.folder-list ul {
41
+ padding-left: 5px;
42
+ }
43
+
44
+ .sh-log-panel ul.folder-list li {
45
+ list-style-type: none;
46
+ margin: 1px 0;
47
+ word-break: break-all;
48
+ cursor: pointer;
49
+ }
50
+
51
+ .sh-log-panel ul.folder-list li:hover > span.basename {
52
+ text-decoration: underline;
53
+ }
54
+
55
+ .sh-log-panel ul.folder-list li .glyphicon-file {
56
+ color: rgb(208, 208, 208) !important; /* light gray */
57
+ }
58
+
59
+ .sh-log-panel ul.folder-list li.directory .glyphicon {
60
+ color: rgb(8, 117, 197); /* blueish */
61
+ }
62
+
63
+ .sh-log-panel ul.folder-list .basename {
64
+ padding: 2px 5px;
65
+ border-radius: 3px;
66
+ }
67
+
68
+ .sh-log-panel ul.folder-list span.chevron {
69
+ color: rgb(145, 145, 145) !important; /* grayish */
70
+ cursor: pointer;
71
+ width: 15px;
72
+ display: inline-block;
73
+ text-align: right;
74
+ }
75
+
76
+ .sh-log-panel ul.folder-list li.directory ul:not(.initial) {
77
+ display: none;
78
+ }
79
+
80
+ .sh-log-panel ul.initial {
81
+ display: block;
82
+ }
83
+
84
+ .sh-log-panel ul.folder-list li.selected > .basename {
85
+ color: white;
86
+ background-color: rgb(8, 117, 197); /* blueish */
87
+ }
88
+
89
+ .sh-log-panel .file-contents {
90
+ text-align: center;
91
+ }
92
+
93
+ .sh-log-panel .file-contents p,
94
+ .sh-log-panel .file-contents pre,
95
+ .sh-log-panel .file-contents label {
96
+ text-align: left;
97
+ margin: 0;
98
+ }
99
+
100
+ .sh-log-panel .file-contents.throbbing {
101
+ padding-top: 100px;
102
+ color: darkred;
103
+ }
104
+
105
+ .sh-log-panel .file-contents .file-details {
106
+ display: inline-block;
107
+ margin-bottom: 10px;
108
+ }
109
+
110
+ .sh-log-panel .file-contents .file-details label {
111
+ min-width: 50px;
112
+ font-size: 12px;
113
+ font-weight: normal;
114
+ }
115
+
116
+ .sh-log-panel .file-contents hr {
117
+ margin: 5px 0;
118
+ }
119
+
120
+ .sh-log-panel .file-contents pre {
121
+ font-size: 10px;
122
+ background-color: white;
123
+ padding: 10px 5px;
124
+ border: none;
125
+ }
126
+
127
+ .sh-log-panel .disp-all-caption {
128
+ font-size: 11px;
129
+ }
@@ -0,0 +1,5 @@
1
+ module LogInspector
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ module LogInspector
2
+ class LogsController < ApplicationController
3
+ def dir_contents
4
+ @directory = params.require :path
5
+ raise "#{@directory} is not a directory" unless File.directory?( @directory )
6
+
7
+ @dir_contents = []
8
+ Dir.glob( "#{@directory.gsub(/[\\\{\}\[\]\*\?]/){|x| "\\"+x}}/*" ) do |dir|
9
+ @dir_contents << {
10
+ is_directory: File.directory?(dir),
11
+ name: File.basename(dir),
12
+ fullpath: dir
13
+ }
14
+ end
15
+ @dir_contents = @dir_contents.sort_by { |f| [ (!f[:is_directory]).to_s, f[:name] ] }
16
+ end
17
+
18
+ def index
19
+ @directory = Rails.application.root.join('log')
20
+ end
21
+
22
+ def file_contents
23
+ fp = params.require :filepath
24
+ raise StandardError, "#{fp} is not a file." unless File.file?(fp)
25
+ @file_contents = {
26
+ basename: File.basename( fp ),
27
+ fullpath: fp,
28
+ lines: %x{wc -l "#{fp}"}.split.first.to_i,
29
+ size: File.size(fp)
30
+ }
31
+ @truncated = @file_contents[:lines] > 500 && !params[:show_all].present?
32
+ @file_contents[:content] = @truncated ? %x{tail -n 500 "#{fp}"} : File.read( fp )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,4 @@
1
+ module LogInspector
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module LogInspector
2
+ module LogsHelper
3
+ def jq_dirpath dir
4
+ dir.gsub("'","\\\\'").html_safe
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>LogInspector</title>
5
+ <script src='https://code.jquery.com/jquery-2.2.4.min.js' integrity='sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=' crossorigin='anonymous'></script>
6
+
7
+ <script src='https://code.jquery.com/ui/1.11.4/jquery-ui.min.js' integrity='sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=' crossorigin='anonymous'></script>
8
+
9
+ <!-- Latest compiled and minified CSS -->
10
+ <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' integrity='sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7' crossorigin='anonymous'>
11
+
12
+ <!-- Optional theme -->
13
+ <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css' integrity='sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r' crossorigin='anonymous'>
14
+
15
+ <!-- Latest compiled and minified JavaScript -->
16
+ <script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js' integrity='sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS' crossorigin='anonymous'></script>
17
+
18
+ <%= stylesheet_link_tag 'log_inspector/application', media: 'all' %>
19
+ <%= javascript_include_tag 'log_inspector/application' %>
20
+ <%= csrf_meta_tags %>
21
+ </head>
22
+ <body>
23
+ <%= yield %>
24
+ </body>
25
+ </html>
@@ -0,0 +1,25 @@
1
+ <div class='file-details'>
2
+ <p>
3
+ <label>File:</label>
4
+ <strong><%= @file_contents[:basename] %></strong>
5
+ </p>
6
+ <p>
7
+ <label>Size:</label>
8
+ <%= number_to_human_size @file_contents[:size] %>
9
+ </p>
10
+ <p>
11
+ <label>Lines:</label>
12
+ <%= number_with_delimiter @file_contents[:lines] %>
13
+ </p>
14
+ </div>
15
+
16
+ <% if @truncated %>
17
+ <p>
18
+ Displaying last 500 lines of <%= @file_contents[:basename] %>.
19
+ <%= link_to 'Show all lines', logs_file_contents_path(filepath: @file_contents[:fullpath], show_all: true), class: 'display-all-lines' %> <span class='disp-all-caption'>(This may respond slowly)</span>
20
+ </p>
21
+ <% end %>
22
+
23
+ <hr/>
24
+
25
+ <pre><%= @file_contents[:content] %></pre>
@@ -0,0 +1,20 @@
1
+ <% if @dir_contents.empty? %>
2
+ <li>No contents.</li>
3
+ <% else %>
4
+ <% @dir_contents.each do |file| %>
5
+ <% if file[:is_directory] %>
6
+ <li class='directory <%= 'classified' if file[:classified] %>' data-full-path="<%= file[:fullpath] %>">
7
+ <span class='chevron glyphicon glyphicon-chevron-right'></span>
8
+ <span class='glyphicon glyphicon-folder-close'></span>
9
+ <span class='basename'><%= file[:name] %></span>
10
+ <ul class='loading'><li>Loading...</li></ul>
11
+ </li>
12
+ <% else %>
13
+ <li class='file' data-full-path="<%= file[:fullpath] %>">
14
+ <span class='chevron'></span>
15
+ <span class='glyphicon glyphicon-file'></span>
16
+ <span class='basename'><%= file[:name] %></span>
17
+ </li>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
@@ -0,0 +1,4 @@
1
+ var ul = $('li[data-full-path="<%= jq_dirpath(@directory) %>"] > ul.loading');
2
+
3
+ ul.removeClass('loading');
4
+ ul.html("<%= j render partial: 'folder_list' %>");
@@ -0,0 +1,3 @@
1
+ $('.file-contents').removeClass('throbbing');
2
+ $('.file-contents').html("<%= j render partial: 'file_contents' %>");
3
+ $(window).trigger('resize');
@@ -0,0 +1,21 @@
1
+ <div class='sh-log-panel'>
2
+ <div class='panel'>
3
+ <ul class='folder-list'>
4
+ <li class='directory' data-full-path="<%= @directory %>">
5
+ <span class='chevron glyphicon glyphicon-chevron-down'></span>
6
+ <span class='glyphicon glyphicon-folder-close'></span>
7
+ <span class='basename'><%= File.basename(@directory) %></span>
8
+ <ul class='loading initial'><li>Loading...</li></ul>
9
+ </li>
10
+ </ul>
11
+ </div>
12
+ </div>
13
+ <div class='sh-log-panel right'>
14
+ <div class='panel file-contents throbbing'>
15
+ Click a file in the left pane to view its contents.
16
+ </div>
17
+ </div>
18
+
19
+ <script>
20
+ intializeLogInspector( '<%= logs_dir_contents_path %>', '<%= logs_file_contents_path %>', "<%= @directory %>" );
21
+ </script>