aws-logs 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/aws_logs/cli.rb +1 -1
- data/lib/aws_logs/core_ext/file.rb +11 -0
- data/lib/aws_logs/tail.rb +15 -1
- data/lib/aws_logs/version.rb +1 -1
- data/lib/aws_logs.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f269c1e0f5e4f2ce2c783602017351445cc9f4849e132005c2de67735531d782
|
4
|
+
data.tar.gz: e43326f8b20d3dad93ab0f61d6bb2b6e14409619093827f6fa3a6f2eced8d369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d3126451461293fa32cd56eb3fe567516b30188387c3aabee1112c03e6d5ceae92dc31e7175c4b20d954c90c5a9464e72f64bc86252f2150692759e59aef85b
|
7
|
+
data.tar.gz: 6499a4bdcd957f85b56e83ff2b159cd4086eab79e04e8de89f61845699a086ff86b2ffd789e7b2c98e896a49af40d70116cb9e1680e663bca0cdd8cf894cd523
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
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.5.0] - 2023-11-22
|
7
|
+
- [#5](https://github.com/tongueroo/aws-logs/pull/5) add options: refresh_rate and wait_exists
|
8
|
+
- alias File.exists?
|
9
|
+
- update tail desc
|
10
|
+
|
6
11
|
## [0.4.1] - 2022-04-23
|
7
12
|
- [#4](https://github.com/tongueroo/aws-logs/pull/4) quiet not found option
|
8
13
|
|
data/lib/aws_logs/cli.rb
CHANGED
@@ -2,7 +2,7 @@ module AwsLogs
|
|
2
2
|
class CLI < Command
|
3
3
|
desc "tail LOG_GROUP", "Tail the CloudWatch log group."
|
4
4
|
long_desc Help.text(:tail)
|
5
|
-
option :since, desc: "From what time to begin displaying logs. By default, logs will be displayed starting from 10m in the past. The value provided can be an ISO 8601 timestamp or a relative time."
|
5
|
+
option :since, desc: "From what time to begin displaying logs. By default, logs will be displayed starting from 10m in the past. The value provided can be an ISO 8601 timestamp or a relative time. Examples: 10m 2d 2w"
|
6
6
|
option :follow, default: true, type: :boolean, desc: " Whether to continuously poll for new logs. To exit from this mode, use Control-C."
|
7
7
|
option :format, default: "detailed", desc: "The format to display the logs. IE: detailed or short. With detailed, the log stream name is also shown."
|
8
8
|
option :log_stream_names, type: :array, desc: "Filters the results to only logs from the log streams. Can only use log_stream_names or log_stream_name_prefix but not both."
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class File
|
2
|
+
class << self
|
3
|
+
# Ruby 3.2 removed File.exists?
|
4
|
+
# aws_config/store.rb uses it
|
5
|
+
# https://github.com/a2ikm/aws_config/blob/ef9cdd0eda116577f7d358bc421afd8e2f1eb1d3/lib/aws_config/store.rb#L6
|
6
|
+
# Probably a bunch of other libraries still use File.exists? also
|
7
|
+
unless method_defined?(:exist?)
|
8
|
+
alias_method :exists?, :exist?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/aws_logs/tail.rb
CHANGED
@@ -6,6 +6,9 @@ module AwsLogs
|
|
6
6
|
super
|
7
7
|
# Setting to ensure matches default CLI option
|
8
8
|
@follow = @options[:follow].nil? ? true : @options[:follow]
|
9
|
+
@refresh_rate = @options[:refresh_rate] || 5
|
10
|
+
@wait_exists = @options[:wait_exists]
|
11
|
+
@wait_exists_retries = @options[:wait_exists_retries]
|
9
12
|
|
10
13
|
@loop_count = 0
|
11
14
|
@output = [] # for specs
|
@@ -46,21 +49,32 @@ module AwsLogs
|
|
46
49
|
# yet. If we don't overlap the sliding window then we'll miss the logs that were delayed in registering.
|
47
50
|
overlap = 60*1000 # overlap the sliding window by a minute
|
48
51
|
since, now = initial_since, current_now
|
52
|
+
@wait_retries ||= 0
|
49
53
|
until end_loop?
|
50
54
|
refresh_events(since, now)
|
51
55
|
display
|
52
56
|
since, now = now-overlap, current_now
|
53
57
|
loop_count!
|
54
|
-
sleep
|
58
|
+
sleep @refresh_rate if @follow && !ENV["AWS_LOGS_TEST"]
|
55
59
|
end
|
56
60
|
# Refresh and display a final time in case the end_loop gets interrupted by stop_follow!
|
57
61
|
refresh_events(since, now)
|
58
62
|
display
|
59
63
|
rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException => e
|
64
|
+
if @wait_exists
|
65
|
+
seconds = 5
|
66
|
+
puts "Waiting for log group #{@log_group_name} to exist. Waiting #{seconds} seconds."
|
67
|
+
sleep seconds
|
68
|
+
@wait_retries += 1
|
69
|
+
if !@wait_exists_retries || @wait_retries < @wait_exists_retries
|
70
|
+
retry
|
71
|
+
end
|
72
|
+
end
|
60
73
|
puts "ERROR: #{e.class}: #{e.message}".color(:red)
|
61
74
|
puts "Log group #{@log_group_name} not found."
|
62
75
|
end
|
63
76
|
|
77
|
+
# TODO: lazy Enum or else its seems stuck for long --since
|
64
78
|
def refresh_events(start_time, end_time)
|
65
79
|
@events = []
|
66
80
|
next_token = :start
|
data/lib/aws_logs/version.rb
CHANGED
data/lib/aws_logs.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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/aws_logs/completer.rb
|
193
193
|
- lib/aws_logs/completer/script.rb
|
194
194
|
- lib/aws_logs/completer/script.sh
|
195
|
+
- lib/aws_logs/core_ext/file.rb
|
195
196
|
- lib/aws_logs/help.rb
|
196
197
|
- lib/aws_logs/help/completion.md
|
197
198
|
- lib/aws_logs/help/completion_script.md
|
@@ -227,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
228
|
- !ruby/object:Gem::Version
|
228
229
|
version: '0'
|
229
230
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
231
|
+
rubygems_version: 3.4.20
|
231
232
|
signing_key:
|
232
233
|
specification_version: 4
|
233
234
|
summary: Tail AWS CloudWatch Logs
|