Sha256: 024915451cf594b556e45cbc2c24f7c0f1c58ed92632b67bd0dd46dd0c007cd5
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
# This file showcases usage of logtail on Ruby projects # For more information visit https://github.com/logtail/logtail-ruby # SETUP # Include logtail library require "logtail" # Check for program arguments if ARGV.length != 1 puts "Program needs source token to run. Run the program as followed\nbundle exec ruby main.rb <source-token>" exit end # Create logger http_device = Logtail::LogDevices::HTTP.new(ARGV[0]) logger = Logtail::Logger.new(http_device) # Filter logs that shouldn't be sent to Better Stack, see {Logtail::LogEntry} for available attributes Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?("DO_NOT_SEND") } # LOGGING # Send debug logs messages using the debug() method logger.debug("Logtail is ready!") # Send informative messages about interesting events using the info() method logger.info("I am using Logtail!") # Send messages about worrying events using the warn() method # You can also log additional structured data logger.warn( "log structured data", item: { url: "https://fictional-store.com/item-123", price: 100.00 } ) # Some messages can be filtered, see {Logtail::Config#filter_sent_to_better_stack} call above logger.info("This message will not be sent to Better Stack because it contains 'DO_NOT_SEND'") # Send error messages using the error() method logger.error("Oops! An error occurred!") # Send messages about fatal events that caused the app to crash using the fatal() method logger.fatal("Application crash! Needs to be fixed ASAP!") puts "All done! You can check your logs now."
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logtail-0.1.13 | example-project/main.rb |
logtail-0.1.12 | example-project/main.rb |