papertrail-cli 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source :rubygems
2
2
 
3
+ gem 'rake', '0.8.7'
4
+
3
5
  gemspec
data/README.md CHANGED
@@ -4,40 +4,48 @@ Small standalone [binary] to retrieve, search, and tail recent app
4
4
  server log and system syslog messages from [Papertrail].
5
5
 
6
6
  Supports optional Boolean search queries and polling for new events
7
- (like "tail -f"). Example:
7
+ (like "tail -f"). Example:
8
8
 
9
9
  papertrail -f "(www OR db) (nginx OR pgsql) -accepted"
10
10
 
11
11
  Output is line-buffered so it can be fed into a pipe, like for grep.
12
+ See below for colorization setup.
12
13
 
13
14
  The [SearchClient] class can be used by other apps to perform one-off
14
15
  API searches or follow (tail) events matching a given query. Interface
15
16
  may change.
16
17
 
17
18
 
18
- ## Quickstart
19
+ ## Quick Start
19
20
 
20
21
  $ [sudo] gem install papertrail-cli
21
- $ echo "username: your@account.com\npassword: yourpass" > ~/.papertrail.yml
22
+ $ echo "token: 123456789012345678901234567890ab" > ~/.papertrail.yml
22
23
  $ papertrail
23
24
 
25
+ Retrieve token from Papertrail [Account Settings].
26
+
24
27
 
25
28
  ## Installation
26
29
 
27
- Install the gem ([RubyGems]), which includes a binary called "papertrail":
30
+ Install the gem (details on [RubyGems]), which includes a binary called
31
+ "papertrail":
28
32
 
29
- $ [sudo] gem install papertrail-cli
33
+ $ [sudo] gem install papertrail-cli
30
34
 
31
35
 
32
36
  ## Configuration
33
37
 
34
- Create ~/.papertrail.yml containing your credentials, or specify the
38
+ Create ~/.papertrail.yml containing your API token, or specify the
35
39
  path to that file with -c. Example (from
36
40
  examples/papertrail.yml.example):
37
- username: your@account.com
38
- password: yourpassword
41
+
42
+ token: 123456789012345678901234567890ab
43
+
44
+ Retrieve token from Papertrail [Account Settings]. For compatibility with
45
+ older config files, `username` and `password` keys are also supported.
39
46
 
40
47
  You may want to alias "trail" to "papertrail", like:
48
+
41
49
  echo "alias trail=papertrail" >> ~/.bashrc
42
50
 
43
51
 
@@ -62,10 +70,27 @@ You may want to alias "trail" to "papertrail", like:
62
70
  More: http://papertrailapp.com/
63
71
 
64
72
 
65
- ## Colorize
73
+ ## Colors
74
+
75
+ Pipe through [colortail] or [MultiTail]. We recommend colortail:
76
+
77
+ $ sudo gem install colortail
78
+
79
+ Save [colortailrc] as `~/.colortailrc` and edit it to enable:
80
+
81
+ $ papertrail -f -d 5 | colortail -g papertrail
82
+
83
+ ### Shorthand
84
+
85
+ If you're using bash, create a function that accepts arguments, then
86
+ invoke `pt` with optional search operators:
87
+
88
+ $ function pt() { papertrail -f -d 5 $_ | colortail -g papertrail }
89
+ $ pt 1.2.3 Failure
90
+
91
+ Add the function line to your `~/.bashrc`.
66
92
 
67
- Pipe through [MultiTail] or [colortail]. For example:
68
- $ papertrail | multitail -c -j
93
+ ### Advanced
69
94
 
70
95
  For complete control, pipe through anything capable of inserting ANSI
71
96
  control characters. Here's an example that colorizes 3 fields separately
@@ -98,7 +123,9 @@ to your enhancement.
98
123
  [binary]: https://github.com/papertrail/papertrail-cli/blob/master/bin/papertrail
99
124
  [Papertrail]: http://papertrailapp.com/
100
125
  [SearchClient]: https://github.com/papertrail/papertrail-cli/blob/master/lib/papertrail/search_client.rb
126
+ [Account Settings]: https://papertrailapp.com/account
101
127
  [RubyGems]: https://rubygems.org/gems/papertrail-cli
128
+ [colortail]: http://rubydoc.info/gems/colortail
129
+ [colortailrc]: https://github.com/papertrail/papertrail-cli/wiki/colortailrc
102
130
  [MultiTail]: http://www.vanheusden.com/multitail/index.html
103
- [colortail]: http://www.codaset.com/elubow/colortail
104
131
  [escape characters]: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
data/bin/papertrail CHANGED
@@ -37,7 +37,11 @@ class PapertrailSearch
37
37
  YAML.load(f)
38
38
  end
39
39
 
40
- client = Papertrail::SearchClient.new(credentials['username'], credentials['password'])
40
+ if credentials['token']
41
+ client = Papertrail::SearchClient.new(:token => credentials['token'])
42
+ else
43
+ client = Papertrail::SearchClient.new(:username => credentials['username'], :password => credentials['password'])
44
+ end
41
45
 
42
46
  search_and_print(client)
43
47
 
@@ -1,2 +1 @@
1
- username: your@account.com
2
- password: yourpassword
1
+ token: 123456789012345678901234567890ab
@@ -1,5 +1,5 @@
1
1
  module PapertrailCli
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
4
4
 
5
5
  require 'papertrail/search_client'
@@ -4,11 +4,7 @@ require 'always_verify_ssl_certificates'
4
4
 
5
5
  module Papertrail
6
6
  class SearchClient
7
- attr_accessor :username, :password, :conn
8
-
9
- def initialize(username, password)
10
- @username = username
11
- @password = password
7
+ def initialize(options)
12
8
 
13
9
  ssl_options = { :verify => OpenSSL::SSL::VERIFY_PEER }
14
10
 
@@ -21,7 +17,11 @@ module Papertrail
21
17
  end
22
18
 
23
19
  @conn = Faraday::Connection.new(:url => 'https://papertrailapp.com', :ssl => ssl_options) do |builder|
24
- builder.basic_auth(@username, @password)
20
+ if options[:username] && options[:password]
21
+ builder.basic_auth(options[:username], options[:password])
22
+ else
23
+ builder.headers['X-Papertrail-Token'] = options[:token]
24
+ end
25
25
 
26
26
  builder.adapter Faraday.default_adapter
27
27
  builder.response :yajl
@@ -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-cli'
16
- s.version = '0.6.1'
17
- s.date = '2011-06-02'
16
+ s.version = '0.7.0'
17
+ s.date = '2011-10-28'
18
18
  s.rubyforge_project = 'papertrail-cli'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papertrail-cli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
7
+ - 7
8
+ - 0
9
+ version: 0.7.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Papertrail
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-06-02 00:00:00 -07:00
17
+ date: 2011-10-28 00:00:00 -07:00
19
18
  default_executable: papertrail
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: yajl-ruby
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 3
30
27
  segments:
31
28
  - 0
32
29
  version: "0"
@@ -36,11 +33,9 @@ dependencies:
36
33
  name: faraday
37
34
  prerelease: false
38
35
  requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
37
  - - ~>
42
38
  - !ruby/object:Gem::Version
43
- hash: 5
44
39
  segments:
45
40
  - 0
46
41
  - 5
@@ -52,11 +47,9 @@ dependencies:
52
47
  name: always_verify_ssl_certificates
53
48
  prerelease: false
54
49
  requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
50
  requirements:
57
51
  - - ">="
58
52
  - !ruby/object:Gem::Version
59
- hash: 3
60
53
  segments:
61
54
  - 0
62
55
  version: "0"
@@ -89,27 +82,23 @@ rdoc_options:
89
82
  require_paths:
90
83
  - lib
91
84
  required_ruby_version: !ruby/object:Gem::Requirement
92
- none: false
93
85
  requirements:
94
86
  - - ">="
95
87
  - !ruby/object:Gem::Version
96
- hash: 3
97
88
  segments:
98
89
  - 0
99
90
  version: "0"
100
91
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
92
  requirements:
103
93
  - - ">="
104
94
  - !ruby/object:Gem::Version
105
- hash: 3
106
95
  segments:
107
96
  - 0
108
97
  version: "0"
109
98
  requirements: []
110
99
 
111
100
  rubyforge_project: papertrail-cli
112
- rubygems_version: 1.4.2
101
+ rubygems_version: 1.3.6
113
102
  signing_key:
114
103
  specification_version: 2
115
104
  summary: Command-line client for Papertrail hosted log management service.