├── .gitignore ├── .rspec ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── bin ├── console └── setup ├── lib └── mina │ ├── logs.rb │ └── logs │ ├── tasks.rake │ └── version.rb └── mina-logs.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | .DS_Store 19 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in mina-logs.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 yafeilee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mina-logs 2 | 3 | A mina plugin that watch production logs in local machine. 4 | 5 | ![Gem version](https://badge.fury.io/rb/mina-logs.svg) 6 | 7 | For mina 0.3.8, please use `0.1.0` version. 8 | 9 | ## Installation 10 | 11 | Add this line to your Rails application's Gemfile: 12 | 13 | ```ruby 14 | gem 'mina-logs', require: false 15 | ``` 16 | 17 | And then execute: 18 | 19 | $ bundle 20 | 21 | ## Usage 22 | 23 | Add this to your `config/deploy.rb` file: 24 | 25 | ```ruby 26 | require 'mina/logs' 27 | ``` 28 | 29 | Then: 30 | 31 | ```shell 32 | # tail -f log/production.log 33 | $ mina logs 34 | # tail -f log/puma.log 35 | $ mina puma_logs 36 | # tail -f log/unicorn.log 37 | $ mina unicorn_logs 38 | # tail -f log/sidekiq.log 39 | $ mina sidekiq_logs 40 | # tail -f log/resque.log 41 | $ mina resque_logs 42 | # tail -f log/xx.log 43 | $ mina '_logs[xx]' 44 | ``` 45 | ## Contributing 46 | 47 | 1. Fork it 48 | 2. Create your feature branch (git checkout -b my-new-feature) 49 | 3. Commit your changes (git commit -am 'Add some feature') 50 | 4. Push to the branch (git push origin my-new-feature) 51 | 5. Create new Pull Request 52 | 53 | 54 | ## License 55 | 56 | The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). 57 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "mina/logs" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start 15 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /lib/mina/logs.rb: -------------------------------------------------------------------------------- 1 | require "mina/logs/version" 2 | load File.expand_path("../logs/tasks.rake", __FILE__) 3 | -------------------------------------------------------------------------------- /lib/mina/logs/tasks.rake: -------------------------------------------------------------------------------- 1 | require 'mina/bundler' 2 | require 'mina/rails' 3 | 4 | if Mina::VERSION >= "1.2.2" 5 | dependent = :remote_environment 6 | else 7 | dependent = :environment 8 | end 9 | 10 | desc "Show production logs" 11 | task logs: dependent do 12 | invoke :'_logs', 'production' 13 | end 14 | 15 | desc "An alias name for `mina logs`" 16 | task log: dependent do 17 | invoke :'logs' 18 | end 19 | 20 | desc "Show puma logs" 21 | task puma_logs: dependent do 22 | invoke :'_logs', 'puma' 23 | end 24 | 25 | desc "Show unicorn logs" 26 | task unicorn_logs: dependent do 27 | invoke :'_logs', 'unicorn' 28 | end 29 | 30 | desc "Show sidekiq logs" 31 | task sidekiq_logs: dependent do 32 | invoke :'_logs', 'sidekiq' 33 | end 34 | 35 | desc "Show resque logs" 36 | task resque_logs: dependent do 37 | invoke :'_logs', 'resque' 38 | end 39 | 40 | task :_logs, [:file] => [dependent] do |_, args| 41 | command %[tail -f #{fetch(:current_path)}/log/#{args[:file]}.log] 42 | end 43 | -------------------------------------------------------------------------------- /lib/mina/logs/version.rb: -------------------------------------------------------------------------------- 1 | module Mina 2 | module Logs 3 | VERSION = "1.1.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /mina-logs.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'mina/logs/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "mina-logs" 8 | spec.version = Mina::Logs::VERSION 9 | spec.authors = ["yafeilee"] 10 | spec.email = ["lyfi2003@gmail.com"] 11 | 12 | spec.summary = %q{Show logs for mina} 13 | spec.description = %q{Show logs for mina} 14 | spec.homepage = "https://github.com/windy/mina-logs" 15 | spec.license = "MIT" 16 | 17 | # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' 18 | # to allow pushing to a single host or delete this section to allow pushing to any host. 19 | if spec.respond_to?(:metadata) 20 | spec.metadata['allowed_push_host'] = "https://rubygems.org" 21 | else 22 | raise "RubyGems 2.0 or newer is required to protect against public gem pushes." 23 | end 24 | 25 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 26 | spec.bindir = "exe" 27 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 28 | spec.require_paths = ["lib"] 29 | 30 | spec.add_dependency 'mina', '>= 1.0.2' 31 | spec.add_development_dependency "bundler", "~> 1.12" 32 | spec.add_development_dependency "rake", "~> 10.0" 33 | spec.add_development_dependency "rspec", "~> 3.0" 34 | end 35 | --------------------------------------------------------------------------------