artanis icon indicating copy to clipboard operation
artanis copied to clipboard

Logging

Open puppetpies opened this issue 8 years ago • 5 comments

Added some abilities to Artanis with Sample file included.

puppetpies avatar Apr 22 '16 09:04 puppetpies

Why didn't you use the stdlib logger?

jhass avatar Apr 22 '16 09:04 jhass

Didn't know about it i will change it!

puppetpies avatar Apr 22 '16 09:04 puppetpies

Crystal already provides a log handler that can be used: https://github.com/crystal-lang/crystal/blob/master/src/http/server/handlers/log_handler.cr

ysbaddaden avatar Apr 22 '16 10:04 ysbaddaden

Ok so you all actually have todo is Add a handler to the HTTP Server and give it an IO location i.e STDOUT or File.open.

Interesting ! I made my logging.cr use the stdlib logger looks like i don't really need it now.

puppetpies avatar Apr 22 '16 10:04 puppetpies

Yes, something as simple as:

log_handler = HTTP::LogHandler.new(STDOUT)
HTTP::Server.new("::1", 9292, [log_handler]) { |ctx| MyApp.call(ctx) }.listen

I think that whatever can be implemented as a Handler should be one, so Artanis is kept minimal. That being said, having access to a logger instance (on demand) would be nice, so I just added that: 689495d3cbd6a85a48c5b04e0c8aa53c659d140a

ysbaddaden avatar Apr 22 '16 20:04 ysbaddaden