1. EuMVC:Logging
- Posted by euphoric (admin) Apr 07, 2022
- 979 views
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...
2. Re: EuMVC:Logging
- Posted by ghaberek (admin) Apr 08, 2022
- 965 views
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...
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
3. Re: EuMVC:Logging
- Posted by euphoric (admin) Apr 11, 2022
- 838 views
See LOGGER.md.
Awesome! Thank you!