#import <Foundation/Foundation.h>
#import <os/log.h>

NS_ASSUME_NONNULL_BEGIN

/// SDK 内部统一日志工具。
///
/// 使用 Apple 原生 `os_log`(iOS 12+ ABI),具备以下优势:
/// - Release 构建中动态值默认标记为 `<private>`,不暴露内部信息
/// - `OS_LOG_TYPE_DEBUG` 级别日志在 Release 中不持久化到磁盘
/// - 支持通过 Console.app / `log stream` 按 subsystem/category 过滤
///
/// 用法:
/// ```objc
/// TQLogNavigationInfo("Page started: %@", url);
/// TQLogDownloadDebug("Cookies count=%d", count);
/// ```
@interface TQLog : NSObject

/// 导航相关日志(WKNavigationDelegate)。category="Navigation"
+ (os_log_t)navigation;

/// 下载相关日志(TQDownloadManager / URLSession download)。category="Download"
+ (os_log_t)download;

@end

#define TQ_LOG_SUBSYSTEM "com.tencent.qian.webview"

#define TQLogNavigationInfo(fmt, ...)   os_log_with_type([TQLog navigation], OS_LOG_TYPE_INFO,    fmt, ##__VA_ARGS__)
#define TQLogNavigationDebug(fmt, ...)  os_log_with_type([TQLog navigation], OS_LOG_TYPE_DEBUG,   fmt, ##__VA_ARGS__)
#define TQLogNavigationError(fmt, ...)  os_log_with_type([TQLog navigation], OS_LOG_TYPE_ERROR,   fmt, ##__VA_ARGS__)

#define TQLogDownloadInfo(fmt, ...)     os_log_with_type([TQLog download],   OS_LOG_TYPE_INFO,    fmt, ##__VA_ARGS__)
#define TQLogDownloadDebug(fmt, ...)    os_log_with_type([TQLog download],   OS_LOG_TYPE_DEBUG,   fmt, ##__VA_ARGS__)
#define TQLogDownloadError(fmt, ...)    os_log_with_type([TQLog download],   OS_LOG_TYPE_ERROR,   fmt, ##__VA_ARGS__)
#define TQLogDownloadWarn(fmt, ...)     os_log_with_type([TQLog download],   OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)

NS_ASSUME_NONNULL_END
