Challenge: Build a Color-Coded Log Viewer for Phix/Euphoria (Inspired by chat.exw)

new topic     » topic index » view thread      » older message » newer message

Challenge: Build a Color-Coded Log Viewer for Euphoria (Inspired by chat.exw)

Hi all,

I am issuing a small but meaningful challenge to the Euphoria/Phix community: Build a color-coded log viewer using IUP, inspired by Pete Lomax's chat.exw.

This is not just a toy idea. It is a genuinely useful debugging tool that could make Euphoria development smoother and more modern.

Specs

  • The viewer receives log entries over TCP/IP.
  • It displays messages in a scrollable panel or list area.
  • Each message affects the background color of all subsequent output, based on log level:

  ERROR:   -> light pink background   
  WARNING: -> yellow background   
  INFO:    -> green background   
  DEBUG:   -> white background   
  VERBOSE: -> white background 
Messages must start with the log level prefix (such as ERROR:). The background color remains in effect until a new prefix is seen.

  • The viewer does not edit log entries. It simply displays them in real-time (or in buffered batches if preferred).

My Role (xecronix / Ronald)

I will modify the following `logger.e` module to optionally write to a TCP/IP socket instead of a log file. This will allow the viewer to receive logs live, without requiring file polling or tailing.

Here is the original version of the logger:

-- logger.e 
-- File: lib/utils/logger.e 
 
include ../shared/constants.e 
include builtins/timedate.e 
 
global enum SILENT, ERR, INFO, DEBUG, TRACE, VERBOSE 
 
integer log_level = VERBOSE 
sequence log_file = "bzscript.log" 
integer log_handle = -1 
 
global procedure init_logger() 
    if not file_exists(log_file) then 
        log_handle = open(log_file, "w") 
    else 
        log_handle = open(log_file, "a") 
    end if 
    if log_handle = -1 then 
        puts(1, "[logger] Failed to open log file.\n") 
        abort(1) 
    end if 
end procedure 
 
global procedure close_logger() 
    if log_handle != -1 then 
        close(log_handle) 
        log_handle = -1 
    end if 
end procedure 
 
procedure log_line(sequence level, sequence msg) 
    sequence td = format_timedate(date(), "YYYY-MM-DD HH:mm:ss") 
    printf(log_handle, "[%s] [%s] %s\n", {td, level, msg}) 
end procedure 
 
procedure log_info(sequence msg) 
    log_line("info", msg) 
end procedure 
 
procedure log_debug(sequence msg) 
    log_line("debug", msg) 
end procedure 
 
procedure log_trace(sequence msg) 
    log_line("trace", msg) 
end procedure 
 
procedure log_error(sequence msg) 
    log_line("error", msg) 
end procedure 
 
procedure log_verbose(sequence msg) 
    log_line("verbose", msg) 
end procedure 
 
global procedure logger(integer level, sequence msg) 
    if log_handle = -1 then 
        init_logger() 
    end if 
    if level <= log_level then 
        if level = SILENT then 
            -- do nothing 
        elsif level = ERR then 
            log_error(msg) 
        elsif level = INFO then 
            log_info(msg) 
        elsif level = DEBUG then 
            log_debug(msg) 
        elsif level = TRACE then 
            log_trace(msg) 
        elsif level = VERBOSE then 
            log_verbose(msg) 
        else 
            log_error("**INVALID LOGGER TYPE**") 
            log_error(msg) 
        end if 
    end if 
end procedure 

Why This Matters

  • Euphoria has always been about simplicity and power. A simple real-time log viewer supports both goals.
  • If no one takes this on, I will write it in FreePascal, create a dll/so, and wrap it for Euphoria.
  • But I would rather see someone here step up and keep this kind of tooling native to the language.

Imagine a custom view of complex data while stepping thru code in the trace program/debugger.
Imagine a custom view of test results simply by logging.

Who's in?

Ronald Weidner

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu