ログの出力方法
既定の AIBuds ロガーが記録する最小ログレベルと、使用する 1 つの出力先を選択します。
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 デバッガーコンソール | 非対応 |
.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 からの相対パスを指定します。先頭のスラッシュは SDK が削除します。maxFileSizeとlogFileMaxAgeに 0 以下の値を指定すると無視されます。- 公開 SDK は、リモートサーバーへのログ設定やカテゴリ別の有効/無効設定を公開していません。