Re: Challenge: Build a Color-Coded Log Viewer for Phix/Euphoria (Inspired by chat.exw)
- Posted by ghaberek (admin) 1 week ago
- 228 views
FYI I wrote a color-coded logging library for Euphoria MVC that I intend to port into the release of Euphoria 4.2.
It uses call_stack() from the newer debug library to provide the call details for each entry. (This only works in the interpreter and is ifdef'd out when translated.)
Features include:
- Logging levels: LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL
- Additional LOG_VERBOSE flag, useful for providing "short" and "long" output
- Log level can be set via Euphoria defines, e.g. eui -D LOG_TRACE app.ex or eu.cfg
- Automatically pretty-prints anything passed to "%s" format specifier
- Custom colors for each log parameter: date, stack info, log text, etc.
- Supports multiple logging targets, e.g set_log_output({STDERR,"app.log"})
- Overwrite log files by specifying "!" at the start of file name (defaults to append)
There are no dependencies on anything else from Euphoria MVC so you can drop it directly into your application.
https://github.com/OpenEuphoria/euphoria-mvc/blob/master/include/mvc/logger.e
Example with default level (LOG_INFO)
Example specifying level LOG_TRACE
-Greg