Commit Graph

3 Commits

Author SHA1 Message Date
Emma Anholt 04cdd41fdc util/log: Add support for logging once.
These are not data-race safe (like many other once patterns in Mesa), so
they might not log exactly once, but it should be good enough for not
spamming the console.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14999>
2022-04-06 00:04:14 +00:00
Emma Anholt 250c127c20 util/log: Add a streaming printf interface.
Often disassemblers and things in our drivers want to be able to
incrementally printf together a line, but that gets in the way of
Android's logging that wants to see a whole line all at once.  Make a
little wrapper to do the ralloc_asprintf_rewrite_tail() and flushing lines
as they appear.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9262>
2021-06-18 18:18:35 +00:00
Eric Anholt 13ea7db760 mesa: Promote Intel's simple logging façade for Android to util/
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
aa716db0f6 ("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: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6806>
2020-09-28 09:14:44 -07:00
Renamed from src/intel/common/intel_log.h (Browse further)