aws-logs 0.2.0 → 0.3.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +1 -1
- data/lib/aws_logs/help/tail.md +2 -2
- data/lib/aws_logs/tail.rb +19 -10
- data/lib/aws_logs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5f2fc9111e29b7a67550c1513dd21b67840279bd3c12538aa5532ef72b2ab4
|
4
|
+
data.tar.gz: e0913aae37e2d27b81959b47a9fa89a74724a2494ebffa956c27acfa982ec6bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ddeb28e8dc13db69efcd1e6c861a4c08f8c800333dbdedb669ee56f6c9fe0fda57ae31c783aea91200156f22120a6cedace8fb2d7fff81d11e6ef537bd4b5cc
|
7
|
+
data.tar.gz: '091350a05ffecae55423ea1fcff0e6914b9db6bf8c8123749667d586fb5ae4459a12f58d02f29f9b2e6b92a8a7028482855536476f7b6604c820e671ded84ad8'
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,21 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.3.4]
|
7
|
+
- set next_token for large filter_log_events responses
|
8
|
+
|
9
|
+
## [0.3.3]
|
10
|
+
- #2 add overlap to window to account for delayed logs received at the same time
|
11
|
+
|
12
|
+
## [0.3.2]
|
13
|
+
- #1 clean up end_loop_signal logic
|
14
|
+
|
15
|
+
## [0.3.1]
|
16
|
+
- fix --no-follow option
|
17
|
+
|
18
|
+
## [0.3.0]
|
19
|
+
- display final logs upon stop_follow!
|
20
|
+
|
6
21
|
## [0.2.0]
|
7
22
|
- add stop_follow! method
|
8
23
|
- friendly error message when log not found
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# aws-logs
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/aws-logs)
|
4
4
|
|
5
5
|
[](https://www.boltops.com)
|
6
6
|
|
data/lib/aws_logs/help/tail.md
CHANGED
@@ -41,7 +41,7 @@ Since supports these formats:
|
|
41
41
|
* d - days
|
42
42
|
* w - weeks
|
43
43
|
|
44
|
-
Since does not
|
44
|
+
Since does not support combining the formats. IE: 5m30s.
|
45
45
|
|
46
46
|
## Filter Pattern
|
47
47
|
|
@@ -52,6 +52,6 @@ To match terms with spaces in it, you'll need quotes around it. Otherise, the ma
|
|
52
52
|
|
53
53
|
aws-logs tail /aws/codebuild/demo --filter-pattern '"Wed Nov 27 23"' --since 3h --no-follow
|
54
54
|
|
55
|
-
Here's an example of matching with an exclude
|
55
|
+
Here's an example of matching with an exclude pattern using the `-` (minus sign).
|
56
56
|
|
57
57
|
aws-logs tail /aws/codebuild/demo --filter-pattern '"ERROR" - "Exiting"' --since 3h --no-follow
|
data/lib/aws_logs/tail.rb
CHANGED
@@ -8,7 +8,7 @@ module AwsLogs
|
|
8
8
|
@options = options
|
9
9
|
@log_group_name = options[:log_group_name]
|
10
10
|
# Setting to ensure matches default CLI option
|
11
|
-
@follow = @options[:follow]
|
11
|
+
@follow = @options[:follow].nil? ? true : @options[:follow]
|
12
12
|
|
13
13
|
@loop_count = 0
|
14
14
|
@output = [] # for specs
|
@@ -35,14 +35,21 @@ module AwsLogs
|
|
35
35
|
return
|
36
36
|
end
|
37
37
|
|
38
|
+
# We overlap the sliding window because CloudWatch logs can receive or send the logs out of order.
|
39
|
+
# For example, a bunch of logs can all come in at the same second, but they haven't registered to CloudWatch logs
|
40
|
+
# yet. If we don't overlap the sliding window then we'll miss the logs that were delayed in registering.
|
41
|
+
overlap = 60*1000 # overlap the sliding window by a minute
|
38
42
|
since, now = initial_since, current_now
|
39
|
-
|
43
|
+
until end_loop?
|
40
44
|
refresh_events(since, now)
|
41
45
|
display
|
42
|
-
since, now = now, current_now
|
46
|
+
since, now = now-overlap, current_now
|
43
47
|
loop_count!
|
44
|
-
sleep 5 if @follow &&
|
48
|
+
sleep 5 if @follow && !ENV["AWS_LOGS_TEST"]
|
45
49
|
end
|
50
|
+
# Refresh and display a final time in case the end_loop gets interrupted by stop_follow!
|
51
|
+
refresh_events(since, now)
|
52
|
+
display
|
46
53
|
rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException => e
|
47
54
|
puts "ERROR: #{e.class}: #{e.message}".color(:red)
|
48
55
|
puts "Log group #{@log_group_name} not found."
|
@@ -58,11 +65,13 @@ module AwsLogs
|
|
58
65
|
log_group_name: @log_group_name, # required
|
59
66
|
start_time: start_time,
|
60
67
|
end_time: end_time,
|
61
|
-
# limit:
|
68
|
+
# limit: 1000,
|
69
|
+
# interleaved: true,
|
62
70
|
}
|
63
71
|
options[:log_stream_names] = @options[:log_stream_names] if @options[:log_stream_names]
|
64
72
|
options[:log_stream_name_prefix] = @options[:log_stream_name_prefix] if @options[:log_stream_name_prefix]
|
65
73
|
options[:filter_pattern] = @options[:filter_pattern] if @options[:filter_pattern]
|
74
|
+
options[:next_token] = next_token if next_token != :start && !next_token.nil?
|
66
75
|
resp = cloudwatchlogs.filter_log_events(options)
|
67
76
|
|
68
77
|
@events += resp.events
|
@@ -97,9 +106,7 @@ module AwsLogs
|
|
97
106
|
return unless follow_until
|
98
107
|
|
99
108
|
messages = @events.map(&:message)
|
100
|
-
|
101
|
-
@@end_loop_signal = true
|
102
|
-
end
|
109
|
+
@@end_loop_signal = messages.detect { |m| m.include?(follow_until) }
|
103
110
|
end
|
104
111
|
|
105
112
|
def say(text)
|
@@ -110,15 +117,17 @@ module AwsLogs
|
|
110
117
|
@output.join("\n") + "\n"
|
111
118
|
end
|
112
119
|
|
113
|
-
@@end_loop_signal = false
|
114
120
|
def set_trap
|
115
121
|
Signal.trap("INT") {
|
116
122
|
puts "\nCtrl-C detected. Exiting..."
|
117
|
-
@@end_loop_signal = true # useful to control loop
|
118
123
|
exit # immediate exit
|
119
124
|
}
|
120
125
|
end
|
121
126
|
|
127
|
+
# The stop_follow! results in a little waiting because it signals to break the polling loop.
|
128
|
+
# Since it's in the middle of the loop process, the loop will finish the sleep 5 first.
|
129
|
+
# So it can pause from 0-5 seconds.
|
130
|
+
@@end_loop_signal = false
|
122
131
|
def self.stop_follow!
|
123
132
|
@@end_loop_signal = true
|
124
133
|
end
|
data/lib/aws_logs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|