test_monolog.rb 577 B

123456789101112131415161718192021222324252627282930313233343536
  1. require 'atto'
  2. include Atto::Test
  3. require_relative '../lib/monolog'
  4. LOG_NAME = '/tmp/monolog_test.log'
  5. assert { Monolog }
  6. assert { Monolog.setup }
  7. assert { Monolog.setup_all(LOG_NAME) }
  8. assert { Monolog.get_log }
  9. assert do
  10. lg = Monolog.get_log.loggers
  11. !(lg.empty?)
  12. end
  13. assert do
  14. Monolog.log_info("bazz")
  15. sleep 1
  16. res = File.read(LOG_NAME)
  17. res =~ /bazz/ && res =~ /INFO/
  18. end
  19. assert "Debug evel is not logged by default after setup_all" do
  20. Monolog.log_debug("frotz")
  21. sleep 1
  22. res = File.read(LOG_NAME)
  23. res !~ /frotz/
  24. end
  25. assert { Monolog.close }