본문으로 건너뛰기

로그 출력 방식

기본 AIBuds 로거가 기록할 최소 로그 레벨과 하나의 출력 대상을 선택합니다.

API Reference

프레임워크

AIBudsLog.xcframework

선언

Swift
/// 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
}

logConfiguration, LogLevelLogDestination을 참고하세요.

로그 레벨

level은 기록할 최소 심각도입니다. 이보다 낮은 레벨의 로그는 기록하지 않습니다.

레벨용도
.verbose세부 실행 흐름을 추적합니다.
.debug개발 중 문제를 진단합니다.
.info일반 진행 상태와 동작 정보를 기록합니다.
.warn확인이 필요할 수 있는 상태를 기록합니다.
.error앱은 계속 실행할 수 있지만 작업이 실패한 상태를 기록합니다.
.fatal앱이 종료될 수 있는 치명적인 실패를 기록합니다.
.mute모든 로그 출력을 끕니다.

출력 대상

출력 대상출력 위치내보내기 지원
.consoleXcode 디버거 Console아니요
.osloggeros_log를 사용하는 Apple 통합 로깅아니요
.file설정한 Documents 상대 경로의 파일
.xlfacilityAIBudsXLFacility 영구 저장 플러그인플러그인이 설치된 경우 지원

사용 예제

Swift
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"
)

참고

  • 출력 대상 설정은 프로세스 전체에 적용되며 이전 설정을 대체합니다. 여러 출력을 동시에 활성화하는 방식이 아닙니다.
  • logsDirectory에는 Documents 기준 상대 경로를 사용합니다. 경로 맨 앞의 slash는 SDK가 제거합니다.
  • maxFileSizelogFileMaxAge에 0 이하의 값을 지정하면 무시됩니다.
  • 공개 SDK는 원격 서버 로깅 설정이나 카테고리별 활성화 스위치를 제공하지 않습니다.