# 1.cr require "log" Log.setup_from_env class MyApp Log = ::Log.for(self) def run Log.debug { "the app is running" } # log from myapp source end end MyApp.new.run Log.info { "finished" } # log from the top-level source
╰─ $ CRYSTAL_LOG_LEVEL=DEBUG CRYSTAL_LOG_SOURCES="*" crystal run 1.cr 2022-09-11T15:14:29.911205Z INFO - finished ╰─ $ crystal --version Crystal 1.6.0-dev [d090fe371] (2022-09-08) LLVM: 14.0.6 Default target: x86_64-pc-linux-gnu
It’s my fault, i read old version 0.34 API document.