papertrail 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -46,7 +46,7 @@ older config files, `username` and `password` keys are also supported.
46
46
 
47
47
  You may want to alias "trail" to "papertrail", like:
48
48
 
49
- echo "alias trail=papertrail" >> ~/.bashrc
49
+ echo "alias pt=papertrail" >> ~/.bashrc
50
50
 
51
51
 
52
52
  ## Usage & Examples
@@ -55,17 +55,21 @@ You may want to alias "trail" to "papertrail", like:
55
55
  papertrail - command-line tail and search for Papertrail log management service
56
56
  -h, --help Show usage
57
57
  -f, --follow Continue running and print new events (off)
58
- -d, --delay SECONDS Delay between refresh (3)
58
+ -d, --delay SECONDS Delay between refresh (2)
59
59
  -c, --configfile PATH Path to config (~/.papertrail.yml)
60
+ -s, --system SYSTEM System to search
61
+ -g, --group GROUP Group to search
60
62
 
61
- Usage: papertrail [-f] [-d seconds] [-c /path/to/papertrail.yml] [query]
63
+ Usage:
64
+ papertrail [-f] [-s system] [-g group] [-d seconds] [-c papertrail.yml] [query]
62
65
 
63
66
  Examples:
64
67
  papertrail -f
65
68
  papertrail something
66
69
  papertrail 1.2.3 Failure
70
+ papertrail -s ns1 "connection refused"
67
71
  papertrail -f "(www OR db) (nginx OR pgsql) -accepted"
68
- papertrail -f -d 10 "ns1 OR 'connection refused'"
72
+ papertrail -f -g Production "(nginx OR pgsql) -accepted"
69
73
 
70
74
  More: http://papertrailapp.com/
71
75
 
data/bin/papertrail CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'papertrail/cli'
4
3
 
5
4
  begin
@@ -7,11 +7,16 @@ module Papertrail
7
7
  class Cli
8
8
  def run
9
9
  options = {
10
- :configfile => File.expand_path('~/.papertrail.yml'),
10
+ :configfile => nil,
11
11
  :delay => 2,
12
12
  :follow => false
13
13
  }
14
14
 
15
+ if configfile = find_configfile
16
+ configfile_options = load_configfile(configfile)
17
+ options.merge!(configfile_options)
18
+ end
19
+
15
20
  OptionParser.new do |opts|
16
21
  opts.banner = "papertrail - command-line tail and search for Papertrail log management service"
17
22
 
@@ -38,15 +43,12 @@ module Papertrail
38
43
  opts.separator usage
39
44
  end.parse!
40
45
 
41
- credentials = open(options[:configfile]) do |f|
42
- YAML.load(f)
46
+ if options[:configfile]
47
+ configfile_options = load_configfile(options[:configfile])
48
+ options.merge!(configfile_options)
43
49
  end
44
50
 
45
- if credentials['token']
46
- connection = Papertrail::Connection.new(:token => credentials['token'])
47
- else
48
- connection = Papertrail::Connection.new(:username => credentials['username'], :password => credentials['password'])
49
- end
51
+ connection = Papertrail::Connection.new(options)
50
52
 
51
53
  query_options = {}
52
54
 
@@ -75,17 +77,41 @@ module Papertrail
75
77
  end
76
78
  end
77
79
 
80
+ def find_configfile
81
+ if File.exists?(path = File.expand_path('.papertrail.yml'))
82
+ return path
83
+ end
84
+ if File.exists?(path = File.expand_path('~/.papertrail.yml'))
85
+ return path
86
+ end
87
+ end
88
+
89
+ def load_configfile(file_path)
90
+ symbolize_keys(YAML.load_file(file_path))
91
+ end
92
+
93
+ def symbolize_keys(hash)
94
+ new_hash = {}
95
+ hash.each do |(key, value)|
96
+ new_hash[(key.to_sym rescue key) || key] = value
97
+ end
98
+
99
+ new_hash
100
+ end
101
+
78
102
  def usage
79
103
  <<-EOF
80
104
 
81
- Usage: papertrail [-f] [-d seconds] [-c /path/to/papertrail.yml] [query]
105
+ Usage:
106
+ papertrail [-f] [-s system] [-g group] [-d seconds] [-c papertrail.yml] [query]
82
107
 
83
108
  Examples:
84
109
  papertrail -f
85
110
  papertrail something
86
111
  papertrail 1.2.3 Failure
112
+ papertrail -s ns1 "connection refused"
87
113
  papertrail -f "(www OR db) (nginx OR pgsql) -accepted"
88
- papertrail -f -d 10 "ns1 OR 'connection refused'"
114
+ papertrail -f -g Production "(nginx OR pgsql) -accepted"
89
115
 
90
116
  More: https://papertrailapp.com/
91
117
 
@@ -14,7 +14,9 @@ module Papertrail
14
14
  def_delegators :@connection, :get, :put, :post
15
15
 
16
16
  def initialize(options)
17
- ssl_options = { :verify => OpenSSL::SSL::VERIFY_PEER }
17
+ ssl_options = {
18
+ :verify => options.fetch(:verify_ssl) { OpenSSL::SSL::VERIFY_PEER }
19
+ }
18
20
 
19
21
  # Make Ubuntu OpenSSL work
20
22
  #
data/lib/papertrail.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Papertrail
2
- VERSION = "0.8.4"
2
+ VERSION = "0.9.0"
3
3
  end
4
4
 
5
5
  require 'papertrail/search_client'
data/papertrail.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'papertrail'
16
- s.version = '0.8.4'
17
- s.date = '2012-02-11'
16
+ s.version = '0.9.0'
17
+ s.date = '2012-02-27'
18
18
  s.rubyforge_project = 'papertrail'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 8
8
- - 4
9
- version: 0.8.4
7
+ - 9
8
+ - 0
9
+ version: 0.9.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Papertrail
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-02-11 00:00:00 -08:00
17
+ date: 2012-02-27 00:00:00 -08:00
18
18
  default_executable: papertrail
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency