Line 13 of stub Routes.pm6 creates new instance of Cro::HTTP::Log::File
Where can I find documentation to this class? For example, if I want to have logs and errors sent to the same file?
I tried using a string for :logs, and got an error. The class wants a file handle. I looked for some documentation, but it's not obvious if there.
Unfortunately, it appears to be lacking documentation. As to how to write the both kinds of log to the same file:
logs
named arguments in the constructor (where it will be automatically used for errors too; you only need pass errors
if they should go to a separate file).It will look something like:
my $logs = open "logs", :w;
my $logger = Cro::HTTP::Log::File.new(:$logs);
This can then be passed along to the Cro::HTTP::Server
's after
(which sets up the middleware to run on responses).
If using cro run
, note that it will automatically restart on changes to files within the directory where a .cro.yml
is present, and so can might end up getting a restart every time something is logged if the log file is in the same directory as the service. Add an ignore to deal with this.