Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference for Log classes

Tags:

raku

cro

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.

like image 282
Richard Hainsworth Avatar asked Nov 18 '19 17:11

Richard Hainsworth


People also ask

What is logging getLogger (__ Name __)?

getLogger(name) is typically executed. The getLogger() function accepts a single argument - the logger's name. It returns a reference to a logger instance with the specified name if provided, or root if not. Multiple calls to getLogger() with the same name will return a reference to the same logger object.

What is logging and why is it important?

The term 'logging' is usually used to denote silviculture activities or forest management. It also encourages the growth and development of new species of trees and is a very important practice as it provides the sustained production of timber.

What are the different log levels?

Logging levels explained. The most common logging levels include FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL, and OFF. Some of them are important, others less important, while others are meta-considerations.

Is logging a standard Python library?

Python provides a logging system as a part of its standard library, so you can quickly add logging to your application.


1 Answers

Unfortunately, it appears to be lacking documentation. As to how to write the both kinds of log to the same file:

  1. Create a file handle by opening a file
  2. Pass it to the 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.

like image 98
Jonathan Worthington Avatar answered Sep 28 '22 08:09

Jonathan Worthington