File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ # This file showcases usage of logtail on Ruby projects
2+ # For more information visit https://github.com/logtail/logtail-ruby
3+
4+ # SETUP
5+
6+ # Include logtail library
7+ require "logtail"
8+
9+ # Check for program arguments
10+ if ARGV . length != 1
11+ puts "Program needs source token to run. Run the program as followed\n ruby main.rb <source-token>"
12+ exit
13+ end
14+ # Create logger
15+ http_device = Logtail ::LogDevices ::HTTP . new ( ARGV [ 0 ] )
16+ logger = Logtail ::Logger . new ( http_device )
17+
18+ # LOGGING
19+
20+ # Send debug logs messages using the debug() method
21+ logger . debug ( "Logtail is ready!" )
22+
23+ # Send informative messages about interesting events using the info() method
24+ logger . info ( "I am using Logtail!" )
25+
26+ # Send messages about worrying events using the warn() method
27+ # You can also log additional structured data
28+ logger . warn (
29+ "log structured data" ,
30+ item : {
31+ url : "https://fictional-store.com/item-123" ,
32+ price : 100.00
33+ }
34+ )
35+
36+ # Send error messages using the error() method
37+ logger . error ( "Oops! An error occurred!" )
38+
39+ # Send messages about fatal events that caused the app to crash using the fatal() method
40+ logger . fatal ( "Application crash! Needs to be fixed ASP!" )
41+
42+ puts "All done! You can check your logs now."
You can’t perform that action at this time.
0 commit comments