capistrano-logtail 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +79 -0
- data/Rakefile +1 -0
- data/capistrano-logtail.gemspec +26 -0
- data/lib/capistrano-logtail.rb +0 -0
- data/lib/capistrano/logtail.rb +3 -0
- data/lib/capistrano/logtail/tasks/logtail.cap +36 -0
- data/lib/capistrano/logtail/utility.rb +48 -0
- data/lib/capistrano/logtail/version.rb +8 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 894f93446c26eef03d09bf56cbd0012dad214afd
|
4
|
+
data.tar.gz: 5566dbcac6ea81f991d86bca4a3376d4f5257c42
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b515e8e72ddbc9531051b878e91b4f7b433322aa58c253b8b085f6c2e4012d963e7ceeb65856f491bb25962e19d9b203b2ac86c8392ee3351b08ced52e539bc
|
7
|
+
data.tar.gz: 7d73c1d1955812ded4179bfb32db5666e63109ded22ec037f09d5b1800b7ccce33a2c482b5346a7a9d1c2bfdd22c5d41bb3a8a0a06277057f6dcad793a5a3eac
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Florian Schwab
|
2
|
+
|
3
|
+
MIT License
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
[![Gem Version](https://img.shields.io/gem/v/capistrano-logtail.svg)](https://rubygems.org/gems/capistrano-logtail)
|
2
|
+
[![Dependencies](https://img.shields.io/gemnasium/ydkn/capistrano-logtail.svg)](https://gemnasium.com/ydkn/capistrano-logtail)
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/ydkn/capistrano-logtail.svg)](https://codeclimate.com/github/ydkn/capistrano-logtail)
|
4
|
+
|
5
|
+
# capistrano-logtail
|
6
|
+
|
7
|
+
Log tailing for capistrano
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'capistrano-logtail'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install capistrano-logtail
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
set :logtail_files, %w( /var/log/syslog )
|
29
|
+
set :logtail_lines, 50
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Require in `Capfile`:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'capistrano/logtail'
|
38
|
+
```
|
39
|
+
|
40
|
+
This will add the following tasks:
|
41
|
+
* logs:tail[]
|
42
|
+
* logs:tail:all
|
43
|
+
* logs:tail:rails
|
44
|
+
|
45
|
+
Add tasks for other log files as required:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# config/deploy.rb
|
49
|
+
|
50
|
+
namespace :logs do
|
51
|
+
namespace :tail do
|
52
|
+
desc 'Tail sidekiq log'
|
53
|
+
task :sidekiq do
|
54
|
+
on roles(:app) do
|
55
|
+
logtail_utility.tail(release_path.join('log', 'sidekiq.log'))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# cap production logs:tail:sidekiq
|
62
|
+
```
|
63
|
+
|
64
|
+
### Examples:
|
65
|
+
|
66
|
+
$ cap production logs:tail:all
|
67
|
+
$ cap production logs:tail:rails
|
68
|
+
$ cap production logs:tail[production] # tails shared/log/production.log
|
69
|
+
$ cap production logs:tail[/var/log/nginx/access.log]
|
70
|
+
$ cap production logs:tail # uses value of logtail_files
|
71
|
+
$ cap production logs:tail n=100 # specify number of existing lines to show
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
1. Fork it
|
76
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
77
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
78
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
79
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/logtail/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-logtail'
|
8
|
+
spec.version = Capistrano::Logtail::VERSION
|
9
|
+
spec.authors = ['Florian Schwab']
|
10
|
+
spec.email = ['me@ydkn.de']
|
11
|
+
spec.description = %q{Log tailing for capistrano}
|
12
|
+
spec.summary = %q{Log tailing for capistrano}
|
13
|
+
spec.homepage = 'https://github.com/ydkn/capistrano-logtail'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'capistrano', '>= 3.0.0', '< 4.0.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'yard'
|
26
|
+
end
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
def logtail_utility
|
2
|
+
@logtail_utility ||= Capistrano::Logtail::Utility.new(self)
|
3
|
+
end
|
4
|
+
|
5
|
+
namespace :logs do
|
6
|
+
desc 'Tail logs'
|
7
|
+
task :tail, :file do |t, args|
|
8
|
+
if args[:file]
|
9
|
+
files = args[:file][0] == '/' ? args[:file] : release_path.join('log', "#{args[:file]}.log")
|
10
|
+
else
|
11
|
+
files = fetch(:logtail_files)
|
12
|
+
end
|
13
|
+
|
14
|
+
fail('Nothing to tail') if files.nil?
|
15
|
+
|
16
|
+
on roles(:app) do
|
17
|
+
logtail_utility.tail(files)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :tail do
|
22
|
+
desc 'Tail rails log'
|
23
|
+
task :rails do
|
24
|
+
on roles(:app) do
|
25
|
+
logtail_utility.tail(release_path.join('log', "#{logtail_utility.rails_env}.log"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Tail all logs'
|
30
|
+
task :all do
|
31
|
+
on roles(:app) do
|
32
|
+
logtail_utility.tail(release_path.join('log', '*.log'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Logtail
|
3
|
+
# Utility stuff to avoid cluttering of logtail.cap
|
4
|
+
class Utility
|
5
|
+
def initialize(context)
|
6
|
+
@context = context
|
7
|
+
end
|
8
|
+
|
9
|
+
# Tail log file(s)
|
10
|
+
def tail(*files)
|
11
|
+
@context.info("Tailing #{files.join(' ')}")
|
12
|
+
|
13
|
+
cmd = [
|
14
|
+
:tail,
|
15
|
+
'-f',
|
16
|
+
"-n#{lines}",
|
17
|
+
*files
|
18
|
+
].join(' ')
|
19
|
+
|
20
|
+
@context.send(:with_ssh) do |ssh|
|
21
|
+
ssh.open_channel do |chan|
|
22
|
+
chan.exec(cmd) do |ch, success|
|
23
|
+
chan.on_data do |ch, data|
|
24
|
+
print data
|
25
|
+
end
|
26
|
+
end
|
27
|
+
chan.wait
|
28
|
+
end
|
29
|
+
ssh.loop
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Rails environment
|
34
|
+
#
|
35
|
+
# @return [String] the rails environment.
|
36
|
+
def rails_env
|
37
|
+
fetch(:rails_env, fetch(:stage, 'production')).to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
# Number of log lines
|
41
|
+
#
|
42
|
+
# @return [Integer] number of existing log lines to show.
|
43
|
+
def lines
|
44
|
+
(ENV['n'] || fetch(:logtail_lines, 10)).to_i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-logtail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florian Schwab
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-30 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.3'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: yard
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: Log tailing for capistrano
|
76
|
+
email:
|
77
|
+
- me@ydkn.de
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- CHANGELOG.md
|
84
|
+
- Gemfile
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- capistrano-logtail.gemspec
|
89
|
+
- lib/capistrano-logtail.rb
|
90
|
+
- lib/capistrano/logtail.rb
|
91
|
+
- lib/capistrano/logtail/tasks/logtail.cap
|
92
|
+
- lib/capistrano/logtail/utility.rb
|
93
|
+
- lib/capistrano/logtail/version.rb
|
94
|
+
homepage: https://github.com/ydkn/capistrano-logtail
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.6
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Log tailing for capistrano
|
118
|
+
test_files: []
|
119
|
+
has_rdoc:
|