capistrano-logger 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44a8bfc2ba70084c0e26ae32328651244af5e9e6
4
+ data.tar.gz: 4d29cea948ff7da18ad86472293f2e614f13c67b
5
+ SHA512:
6
+ metadata.gz: a1d743c2692ebdda03b12bee4280ed7a49015c40200db6a77d77653d1c3c7401c205eb54482411ed6c8fea9e29eaf384a191b7e1de7857a2d612144264251daf
7
+ data.tar.gz: 652f86b828ad29bc3f71bd8dd8c423861635bc754cbdf217a1174bb6d2394d00acbea636be5154a00adf397fe0737c3b60e6d590a3df60c6ff9560aa70e1e64e
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /bin/
11
+ *.gem
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ # License
2
+
3
+ Copyright (c) 2016 Alexander Shlinchak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,74 @@
1
+ # Capistrano::Logger
2
+ Show your logs with Capistrano.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'capistrano-logger', group: :development, github: 'ashlinchak/capistrano-logger'
10
+ ```
11
+ or:
12
+ ```ruby
13
+ gem 'capistrano-logger', group: :development
14
+ ```
15
+ And then execute:
16
+ ```
17
+ $ bundle
18
+ ```
19
+
20
+ Or install it yourself as:
21
+ ```
22
+ $ gem install capistrano-logger
23
+ ```
24
+
25
+ ## Configuration
26
+ Require in `Capfile` to use it:
27
+ ```ruby
28
+ require 'capistrano/logger'
29
+ ```
30
+
31
+ Add configuration options for your deployment environment (if you need to change default behavior):
32
+
33
+ ```ruby
34
+ # production.rb
35
+
36
+ set :logger_default_file, "#{deploy_to}/shared/log/puma_error.log" # default <release_path>/log/<rails_env>.log
37
+
38
+ set :logger_lines, 500 # default 100
39
+
40
+ set :logger_file_aliases, {
41
+ puma_err: "#{deploy_to}/shared/log/puma_error.log",
42
+ nginx_err: '/var/log/nginx/error.log'
43
+ }
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ Show last 100 lines from the `production.log`:
49
+ ```
50
+ $ bundle exec cap production logger:show
51
+ ```
52
+
53
+ Show last 50 lines from the `puma_error.log` using `logger_file_aliases` setting:
54
+ ```
55
+ $ bundle exec cap production logger:show LINES=50 ALIASE=puma_err
56
+ ```
57
+ Show last 50 lines from the target file on the server:
58
+ ```
59
+ $ bundle exec cap production logger:show LINES=50 FILE=/var/log/mysql.log
60
+ ```
61
+
62
+ ## Contributing
63
+
64
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ashlinchak/capistrano-logger.
65
+
66
+ ## License
67
+
68
+ Copyright (c) 2016 Alexander Shlinchak
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/logger/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capistrano-logger'
8
+ spec.version = Capistrano::Logger::VERSION
9
+ spec.authors = ['Alexander Shlinchak']
10
+ spec.email = ['ashlinchak@gmail.com']
11
+ spec.summary = 'Show logs via capistrano.'
12
+ spec.description = 'Show your logs with capistrano.'
13
+ spec.homepage = 'https://github.com/ashlinchak/capistrano-logger'
14
+ spec.licenses = ['MIT']
15
+
16
+ spec.platform = Gem::Platform::RUBY
17
+ spec.required_ruby_version = '>= 1.9.3'
18
+
19
+ spec.files = `git ls-files`.split("\n")
20
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'capistrano', '>= 3.0.0', '< 4.0.0'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.10'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ end
@@ -0,0 +1,4 @@
1
+ require 'capistrano/logger/version'
2
+ require 'capistrano/logger/error'
3
+ load File.expand_path('../logger/tasks/logger.rake', __FILE__)
4
+ load File.expand_path('../logger/sshkit/formatters/log_format.rb', __FILE__)
@@ -0,0 +1,6 @@
1
+ module Capistrano
2
+ module Logger
3
+ class Error < ::StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'sshkit/formatters/pretty'
2
+
3
+ module SSHKit
4
+ module Formatter
5
+ class LogFormat < Pretty
6
+
7
+ alias pretty_colorize colorize
8
+ def colorize(obj, _color, _mode = nil)
9
+ obj.to_s
10
+ end
11
+
12
+ def format_message(_verbosity, message, _uuid=nil)
13
+ message
14
+ end
15
+
16
+ def log_command_start(command)
17
+ host_prefix = command.host.user ? "as #{pretty_colorize(command.host.user, :blue)}@" : 'on '
18
+ message = "Running #{pretty_colorize(command, :yellow, :bold)} #{host_prefix}#{pretty_colorize(command.host, :blue)}"
19
+ write_message(command.verbosity, message, command.uuid)
20
+ end
21
+
22
+ def log_command_exit(command)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ namespace :logger do
2
+ desc 'Show logs'
3
+ task :show do
4
+ on roles(:app) do
5
+ default_file = fetch(:logger_default_file) || "#{release_path}/log/#{fetch(:rails_env)}.log"
6
+ lines = ENV['LINES'] || fetch(:logger_lines) || 100
7
+
8
+ if ENV['ALIASE']
9
+ if fetch(:logger_file_aliases).is_a?(Hash) && fetched_file = fetch(:logger_file_aliases)[ENV['ALIASE'].to_sym]
10
+ file = fetched_file
11
+ else
12
+ raise Capistrano::Logger::Error, 'Aliase for log file is not set.'
13
+ end
14
+ elsif ENV['FILE']
15
+ file = ENV['FILE']
16
+ else
17
+ file = default_file
18
+ end
19
+
20
+ SSHKit.config.use_format SSHKit::Formatter::LogFormat
21
+ execute "tail -n #{lines} #{file}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Logger
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Shlinchak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.10'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.10'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ description: Show your logs with capistrano.
62
+ email:
63
+ - ashlinchak@gmail.com
64
+ executables:
65
+ - console
66
+ - setup
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - ".gitignore"
71
+ - ".travis.yml"
72
+ - Gemfile
73
+ - LICENSE.md
74
+ - README.md
75
+ - Rakefile
76
+ - bin/console
77
+ - bin/setup
78
+ - capistrano-logger.gemspec
79
+ - lib/capistrano/logger.rb
80
+ - lib/capistrano/logger/error.rb
81
+ - lib/capistrano/logger/sshkit/formatters/log_format.rb
82
+ - lib/capistrano/logger/tasks/logger.rake
83
+ - lib/capistrano/logger/version.rb
84
+ homepage: https://github.com/ashlinchak/capistrano-logger
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.9.3
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.6.1
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Show logs via capistrano.
108
+ test_files: []