로그 출력 방식
기본 AIBuds 로거가 기록할 최소 로그 레벨과 하나의 출력 대상을 선택합니다.
API Reference
프레임워크
AIBudsLog.xcframework
선언
- Swift
- Objective-C
/// The current log configuration.
static var logConfiguration: LogConfiguration { get }
/// Configures log storage, rotation, and output behavior.
final class LogConfiguration: NSObject {
/// The severity threshold. Defaults to `.info`.
var level: LogLevel
/// The active output destination. Defaults to `.xlfacility`.
var destination: LogDestination
/// Relative log directory under Documents. Defaults to `.aibuds/logs`.
var logsDirectory: String
/// Maximum single file size. Defaults to 10 MB.
var maxFileSize: UInt64
/// Maximum retained age in days. Defaults to 3.
var logFileMaxAge: Int
}/// The current log configuration.
@property(nonatomic, class, readonly, strong) AIBudsLogConfiguration *logConfiguration;
/// Configures log storage, rotation, and output behavior.
@interface AIBudsLogConfiguration : NSObject
/// The severity threshold. Defaults to `AIBudsLogLevelInfo`.
@property(nonatomic) AIBudsLogLevel level;
/// The active output destination. Defaults to XLFacility.
@property(nonatomic) AIBudsLogDestination destination;
/// Relative log directory under Documents. Defaults to `.aibuds/logs`.
@property(nonatomic, copy) NSString *logsDirectory;
/// Maximum single file size. Defaults to 10 MB.
@property(nonatomic) uint64_t maxFileSize;
/// Maximum retained age in days. Defaults to 3.
@property(nonatomic) NSInteger logFileMaxAge;
@endlogConfiguration, LogLevel 및 LogDestination을 참고하세요.
로그 레벨
level은 기록할 최소 심각도입니다. 이보다 낮은 레벨의 로그는 기록하지 않습니다.
| 레벨 | 용도 |
|---|---|
.verbose | 세부 실행 흐름을 추적합니다. |
.debug | 개발 중 문제를 진단합니다. |
.info | 일반 진행 상태와 동작 정보를 기록합니다. |
.warn | 확인이 필요할 수 있는 상태를 기록합니다. |
.error | 앱은 계속 실행할 수 있지만 작업이 실패한 상태를 기록합니다. |
.fatal | 앱이 종료될 수 있는 치명적인 실패를 기록합니다. |
.mute | 모든 로그 출력을 끕니다. |
출력 대상
| 출력 대상 | 출력 위치 | 내보내기 지원 |
|---|---|---|
.console | Xcode 디버거 Console | 아니요 |
.oslogger | os_log를 사용하는 Apple 통합 로깅 | 아니요 |
.file | 설정한 Documents 상대 경로의 파일 | 예 |
.xlfacility | AIBudsXLFacility 영구 저장 플러그인 | 플러그인이 설치된 경우 지원 |
사용 예제
- Swift
- Objective-C
import AIBudsLog
import AIBudsXLFacility
let configuration = AIBudsLogSDK.logConfiguration
configuration.level = .debug
configuration.destination = .xlfacility
configuration.logFileMaxAge = 7
AIBudsLogSDK.setXLFacilityPlugin(XLFacilitySDK.shared)
AIBudsLogSDK.logService.info(
"SDK configured",
subsystem: "com.example.app",
category: "startup"
)#import <AIBudsLog/AIBudsLog-Swift.h>
#import <AIBudsXLFacility/AIBudsXLFacility-Swift.h>
AIBudsLogConfiguration *configuration = AIBudsLogSDK.logConfiguration;
configuration.level = AIBudsLogLevelDebug;
configuration.destination = AIBudsLogDestinationXlfacility;
configuration.logFileMaxAge = 7;
[AIBudsLogSDK setXLFacilityPlugin:AIBudsXLFacilitySDK.shared];
[AIBudsLogSDK.logService info:@"SDK configured" subsystem:@"com.example.app" category:@"startup"];참고
- 출력 대상 설정은 프로세스 전체에 적용되며 이전 설정을 대체합니다. 여러 출력을 동시에 활성화하는 방식이 아닙니다.
logsDirectory에는 Documents 기준 상대 경로를 사용합니다. 경로 맨 앞의 slash는 SDK가 제거합니다.maxFileSize와logFileMaxAge에 0 이하의 값을 지정하면 무시됩니다.- 공개 SDK는 원격 서버 로깅 설정이나 카테고리별 활성화 스위치를 제공하지 않습니다.