livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
log.hpp File Reference

Opt-in diagnostic logging (issue #42). More...

#include <cstdint>
#include <expected>
#include <filesystem>
#include <functional>
#include <string>
#include <string_view>
#include "livox/mid360/event.hpp"
#include "livox/mid360/export.hpp"

Go to the source code of this file.

Classes

struct  livox::mid360::LogRecord
 One diagnostic record. The views are valid only during the handler call. More...

Namespaces

namespace  livox
 Livox LiDAR drivers.
namespace  livox::mid360
 The livox_mid360_core library: everything declared by the public headers.

Typedefs

using livox::mid360::LogHandler = std::function<void(const LogRecord &)>
 Called from the Context receive thread, the Device worker thread and caller threads, never while an SDK mutex is held.

Enumerations

enum class  livox::mid360::LogLevel : std::uint8_t {
  livox::mid360::kOff , livox::mid360::kError , livox::mid360::kWarn , livox::mid360::kInfo ,
  livox::mid360::kDebug , livox::mid360::kTrace
}
 Severity, ordered: a level is emitted when it is <= the level set with set_log_level(). More...

Functions

void livox::mid360::set_log_level (LogLevel level) noexcept
 Process-wide.
LogLevel livox::mid360::log_level () noexcept
 Current process-wide level, see set_log_level().
void livox::mid360::set_log_handler (LogHandler handler)
 Process-wide; safe to call while a Context is running.
std::string livox::mid360::format_log_record (const LogRecord &record)
 2026-09-26T12:34:56.789Z W [serial] message (UTC, millisecond precision, one-letter level E/W/I/D/T, [-] when the serial is empty).
LogHandler livox::mid360::stderr_log_handler ()
 Writes format_log_record() + '
' to stderr.
std::expected< LogHandler, DeviceError > livox::mid360::file_log_handler (const std::filesystem::path &path, bool append=true)
 Opens (creates or, with append, extends) path and returns a handler that writes format_log_record() + '
' and flushes after every record.
std::string_view livox::mid360::to_string (LogLevel level) noexcept
 Lower-case name, e.g. "warn".

Detailed Description

Opt-in diagnostic logging (issue #42).

Silent by default: the SDK never writes to the console unless the application installs a handler. Unrelated to the LiDAR firmware log stream (port 56500, 0x03xx commands), see firmware_log.hpp / Device::on_firmware_log (#44).