53 lines
1.7 KiB
C
53 lines
1.7 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright 2026 Suyono
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#pragma once
|
|
|
|
// Log level constants shared between C/C++ and Rust
|
|
typedef enum {
|
|
RUST_LOG_LEVEL_FATAL = 0,
|
|
RUST_LOG_LEVEL_ERROR = 1,
|
|
RUST_LOG_LEVEL_WARN = 2,
|
|
RUST_LOG_LEVEL_INFO = 3,
|
|
RUST_LOG_LEVEL_DEBUG = 4,
|
|
RUST_LOG_LEVEL_TRACE = 5,
|
|
} RustLogLevel;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Initialize logging
|
|
void rust_init_logging(const char* log_path);
|
|
|
|
// Authenticate user (stub)
|
|
int rust_auth_user(const char* user, const char* password);
|
|
|
|
// Legacy: Log event (file sink) — forwards to INFO level on Rust side
|
|
void rust_log_event(const char* event);
|
|
|
|
// New: Log event with explicit level
|
|
void rust_log_event_with_level(const char* event, RustLogLevel level);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
// Convenience macros for C/C++ callers
|
|
#define RUST_LOG_FATAL(msg) rust_log_event_with_level((msg), RUST_LOG_LEVEL_FATAL)
|
|
#define RUST_LOG_ERROR(msg) rust_log_event_with_level((msg), RUST_LOG_LEVEL_ERROR)
|
|
#define RUST_LOG_WARN(msg) rust_log_event_with_level((msg), RUST_LOG_LEVEL_WARN)
|
|
#define RUST_LOG_INFO(msg) rust_log_event_with_level((msg), RUST_LOG_LEVEL_INFO)
|
|
#define RUST_LOG_DEBUG(msg) rust_log_event_with_level((msg), RUST_LOG_LEVEL_DEBUG)
|
|
#define RUST_LOG_TRACE(msg) rust_log_event_with_level((msg), RUST_LOG_LEVEL_TRACE)
|
|
|
|
// C wrapper: printf-style helpers (header-only)
|
|
#include "rust_backend_logging_c.h"
|
|
#ifdef __cplusplus
|
|
#include "rust_backend_logging_cpp.h"
|
|
#endif
|
|
|