cro-http-log-file

Cro::HTTP::Log::File

This response middleware provides basic logging of requests to a file handle. By default, it logs both successful requests (response code less than 400) and errors (response code at least 400) to $*OUT (the standard out file handle), which is likely suitable for container deployment and development. To avoid any buffering issues delaying logs, it also defaults to flushing after each output.

Using Alternate File Handles

To log all requests (both success and error) to another location, pass the logs parameter:

my $logger = Cro::HTTP::Log::File.new(logs => open('http.log', :a));

To log errors to a different file, also pass the errors parameter:

my $logger = Cro::HTTP::Log::File.new:
    logs => open('http.log', :a),
    errors => open('error.log', :a);

Controlling flushing

To disable flushing of logs after each write, set the flush option to False:

my $logger = Cro::HTTP::Log::File.new:
    logs => open('http.log', :a),
    flush => False;

If you need something more complex

If you want logs in a different format or sent elsewhere, check in the Raku module ecosystem to see if somebody already wrote such a module or, failing that, implement it by writing a custom response middleware and using it in place of Cro::HTTP::Log::File.

cro v0.8.8

Libraries and tools for building reactive services in Raku. This installs the cro command line and web tool, along with HTTP (including HTTPS and HTTP/2.0) and WebSocket support.

Authors

  • Jonathan Worthington

License

Artistic-2.0

Dependencies

IO::Socket::Async::SSLJSON::FastMETA6Shell::CommandFile::FindTerminal::ANSIColorOO::MonitorsYAMLishCro::WebSocket:ver<0.8.8>Docker::FileFile::Ignore

Test Dependencies

Provides

  • Cro::Tools::CLI
  • Cro::Tools::CroFile
  • Cro::Tools::Link::Editor
  • Cro::Tools::LinkTemplate
  • Cro::Tools::LinkTemplate::HTTP
  • Cro::Tools::LinkTemplate::HTTPS
  • Cro::Tools::LinkTemplate::WS
  • Cro::Tools::LinkTemplate::WSS
  • Cro::Tools::Runner
  • Cro::Tools::Serve
  • Cro::Tools::Services
  • Cro::Tools::Template
  • Cro::Tools::Template::Common
  • Cro::Tools::Template::HTTPService
  • Cro::Tools::Template::ReactReduxSPA
  • Cro::Tools::Template::ZeroMQWorkSinkService
  • Cro::Tools::Template::ZeroMQWorkerService
  • Cro::Tools::TemplateLocator
  • Cro::Tools::Web

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.