MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Loading...
Searching...
No Matches
logging.h File Reference

Go to the source code of this file.

Typedefs

typedef uint32_t(* mln_log_callback) (void *user_data, uint32_t severity, uint32_t event, int64_t code, const char *message)
 

Enumerations

enum  mln_log_severity : uint32_t
 
enum  mln_log_severity_mask : uint32_t
 
enum  mln_log_event : uint32_t
 

Functions

mln_status mln_log_set_callback (mln_log_callback callback, void *user_data)
 
mln_status mln_log_clear_callback (void)
 
mln_status mln_log_set_async_severity_mask (uint32_t mask)
 

Detailed Description

Public C API declarations for logging.

Typedef Documentation

◆ mln_log_callback

typedef uint32_t(* mln_log_callback) (void *user_data, uint32_t severity, uint32_t event, int64_t code, const char *message)

Receives a MapLibre Native log record.

The message pointer is borrowed for the callback duration. Returning non-zero consumes the record. Returning zero lets MapLibre Native's platform logger handle it.

Enumeration Type Documentation

◆ mln_log_event

enum mln_log_event : uint32_t

Log event categories emitted by MapLibre Native.

◆ mln_log_severity

enum mln_log_severity : uint32_t

Log severity values emitted by MapLibre Native.

◆ mln_log_severity_mask

enum mln_log_severity_mask : uint32_t

Bitmask values for log severities dispatched asynchronously.

Function Documentation

◆ mln_log_clear_callback()

mln_status mln_log_clear_callback ( void )

Clears the process-global log callback.

After this call succeeds, future log dispatches no longer use the callback that was previously registered through mln_log_set_callback().

Returns:

  • MLN_STATUS_OK on success.
  • MLN_STATUS_NATIVE_ERROR when an internal exception is converted to status.

◆ mln_log_set_async_severity_mask()

mln_status mln_log_set_async_severity_mask ( uint32_t mask)

Controls which log severities MapLibre Native may dispatch asynchronously.

MLN_LOG_SEVERITY_MASK_DEFAULT restores MapLibre Native's default behavior: info and warning records may be asynchronous, while error records remain synchronous.

Returns:

  • MLN_STATUS_OK on success.
  • MLN_STATUS_INVALID_ARGUMENT when mask contains unknown bits.
  • MLN_STATUS_NATIVE_ERROR when an internal exception is converted to status.

◆ mln_log_set_callback()

mln_status mln_log_set_callback ( mln_log_callback callback,
void * user_data )

Installs a process-global MapLibre Native log callback.

Passing null clears the current callback. The callback and user_data are stored by reference and must remain valid until the callback is replaced or cleared.

The callback is a low-level native callback:

  • MapLibre may invoke it from logging or worker threads selected by the async severity mask.
  • MapLibre may invoke it while holding internal logging locks.
  • The callback must be thread-safe, return quickly, and must not call this C API or MapLibre Native APIs.
  • Language adapters for runtimes that restrict native-thread callbacks can marshal records into host-managed logging facilities before invoking user code.

Returns:

  • MLN_STATUS_OK on success.
  • MLN_STATUS_NATIVE_ERROR when an internal exception is converted to status.