forked from logtail/logtail-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
72 lines (65 loc) · 2.04 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require "bundler/gem_tasks"
require "logtail"
def puts_with_level(message, level = :info)
case level
when :info
puts("\e[31m#{message}\e[0m")
when :error
puts("\e[31m#{message}\e[0m")
when :success
puts("\e[32m#{message}\e[0m")
else
puts(message)
end
end
task :test_the_pipes, [:source_token] do |t, args|
support_email = "[email protected]"
# Do not modify below this line. It's important to keep the `Logtail::Logger`
# because it provides an API for logging structured data and capturing context.
header = <<~HEREDOC
### I want our own pixelart too, but no time for that for now ###
HEREDOC
puts header
current_context = Logtail::CurrentContext.instance.snapshot
entry = Logtail::LogEntry.new(:info, Time.now, nil, "Testing the pipes (click the inspect icon to view more details)", current_context, nil)
http_device = Logtail::LogDevices::HTTP.new(args.source_token, flush_continuously: false)
response = http_device.deliver_one(entry)
if response.is_a?(Exception)
message = <<~HEREDOC
Unable to deliver logs.
Here's what we received from the Logtail API:
#{response.inspect}
If you continue to have trouble please contact support:
#{support_email}
HEREDOC
puts_with_level(message, :error)
elsif response.is_a?(Net::HTTPResponse)
if response.code.start_with? '2'
puts_with_level("Logs successfully sent! View them at https://logtail.com",
:success)
else
message =
<<~HEREDOC
Unable to deliver logs.
We received a #{response.code} response from the Logtail API:
#{response.body.inspect}
If you continue to have trouble please contact support:
#{support_email}
HEREDOC
puts_with_level(message, :error)
end
end
end
task :console do
require 'irb'
require 'irb/completion'
require 'logtail'
$VERBOSE = nil
def reload!
files = $LOADED_FEATURES.select { |feat| feat =~ /\/logtail\// }
files.each { |file| load file }
"reloaded"
end
ARGV.clear
IRB.start
end