1. EuMVC:Logging

Greg!

Can you briefly explain what I need to do to get a basic logger going?

I searched the forum for "logger," but the search functionality is still woefully inadequate... grin

new topic     » topic index » view message » categorize

2. Re: EuMVC:Logging

euphoric said...

Can you briefly explain what I need to do to get a basic logger going?

I searched the forum for "logger," but the search functionality is still woefully inadequate... grin

I've written docs for most of the features of EuMVC. See LOGGER.md. Basically all you have to do is include mvc/logger.e and then pepper your code with various log_xxx() calls as needed. Then define your log level either in code with set_log_level() or via preprocessor defines (e.g. eui -D LOG_DEBUG) which can also be added to your eu.cfg file.

[all] 
-i ../euphoria-mvc/include 
-D LOG_DEBUG 

One way I use logging is to put log_trace() calls at the entry point for each routine, like this:

function index( object request ) 
    log_trace( "request=%s", {map:pairs(request)} ) 
 
    object response = map:new() 
    map:put( response, "title", "My First App" ) 
    map:put( response, "message", "Hello, world!" ) 
 
    return render_template( "index.html", response ) 
end function 
app:route( "/", "index" ) 

Which will result in this output when LOG_TRACE is enabled, complete with color-coded fields for date/time, log level, calling location, and pretty printed values.

2022/04/08 11:22:51 TRACE index@example.ex:43 request={{"REQUEST_HEADERS",12},{"PATH_INFO","/"},{"REQUEST_METHOD","GET"},{"QUERY_STRING",""}} 

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: EuMVC:Logging

ghaberek said...

See LOGGER.md.

Awesome! Thank you!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu