Skip to content
  • Eric Anholt's avatar
    mesa: Promote Intel's simple logging façade for Android to util/ · 13ea7db7
    Eric Anholt authored
    I'm bringing up freedreno Vulkan on an Android phone, and my pains are
    exactly what Chad said when working on Intel's vulkan for Android in
    aa716db0
    
     ("intel: Add simple logging façade for Android (v2)"):
    
        On Android, stdio goes to /dev/null. On Android, remote gdb is even
        more painful than the usual remote gdb. On Android, nothing works like
        you expect and debugging is hell. I need logging.
    
        This patch introduces a small, simple logging API that can easily wrap
        Android's API. On non-Android platforms, this logger does nothing
        fancy.  It follows the time-honored Unix tradition of spewing
        everything to stderr with minimal fuss.
    
        My goal here is not perfection. My goal is to make a minimal, clean API,
        that people hate merely a little instead of a lot, and that's good
        enough to let me bring up Android Vulkan.  And it needs to be fast,
        which means it must be small. No one wants to their game to miss frames
        while aiming a flaming bow into the jaws of an angry robot t-rex, and
        thus become t-rex breakfast, because some fool had too much fun desiging
        a bloated, ideal logging API.
    
    Compared to trusty fprintf, _mesa_log[ewi]() is actually usable on
    Android.  Compared to os_log_message(), this has different error levels
    and supports format arguments.
    
    The only code change in the move is wrapping flockfile/funlockfile in
    !DETECT_OS_WINDOWS, since mingw32 doesn't have it.  Windows likely wants
    different logging code, anyway.
    
    Reviewed-by: default avatarTapani Pälli <tapani.palli@intel.com>
    Reviewed-by: default avatarKristian H. Kristensen <hoegsberg@google.com>
    Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6806>
    13ea7db7