Commit graph

1 commit

Author SHA1 Message Date
Hugo Parente Lima
19d3913b5d
Embrace Crystal standard Log for logging. (#705)
* Embrace Crystal standard Log for logging.

Kemal uses a LogHandler to log requests, this code predates the
Crystal Log class so while the Kemal documentation says that logging is
done using Log class, the http request log is done in a different way.

This patch deprecates:
- Kemal::Config#logger
- Kemal::Config#logger=(Kemal::BaseLogHandler)
- log(String)
- Kemal::LogHandler.initialize(IO)
- NullLogHandler

and changes:

- Add Kemal::Log (Log = ::Log.for(self))
- Kemal::LogHandler now uses Log.
- No handler is created if logging is set to false.

Old code using custom log handlers must work as before.

* Let ExceptionHandler use Log instead of log.

* Deprecate Kemal::LogHandler and adds Kemal::RequestLogHandler.

* Don't break API on Kemal#logger.

* Add test for Kemal::RequestLogHandler.

* Do not log redundant informations like timestamp and exception message.

* Use ex.message on unexpected exceptions log message.
2025-04-01 13:25:09 +03:00