piotrmurach/tty-logger

View on GitHub
examples/console.rb

Summary

Maintainability
A
15 mins
Test Coverage
# frozen_string_literal: true

require_relative "../lib/tty/logger"

TTY::Logger.configure do |config|
  config.max_bytes = 2**5
  config.metadata = [:all]
  config.handlers = [[:console, { formatter: :text }]]
  config.level = :debug
end

logger = TTY::Logger.new(fields: { app: "myapp", env: "prod" })

logger.copy(path: "/var/www/example.com").info("Deploying", "code")

puts "Levels:"

logger.debug("Debugging deployment")
logger.info("Info about the deploy")
logger.warn("Lack of resources")
logger.error("Failed to deploy")
logger.fatal("Terribly failed to deploy")
logger.success("Deployed successfully")
logger.wait("Ready to deploy")