AppleDiagnosticLogWriter

class AppleDiagnosticLogWriter(rootPath: String, streamName: String = "app", diagnosticLoggingEnabled: Boolean = false, fileSystem: FileSystem = FileSystem.SYSTEM, maxFileBytes: Long = DEFAULT_MAX_FILE_BYTES, rolledFiles: Int = DEFAULT_ROLLED_FILES) : LogWriter

Opt-in, app-lifetime file writer shared by Apple hosts. The host owns preferences and logger configuration. Use distinct stream names for the app and extensions. All instances sharing a root coordinate through flock.

Writes are best effort: a full submission queue, unavailable storage, or another process holding the lock drops the entry. Entries over 32K message/tag characters and queues over 256K characters are also dropped. Throwable references are retained until processing; their stack traces are formatted only on the IO queue. Lock acquisition never waits. Accepted entries close their sinks before the next queue operation. File IO itself can stall; extension completion must use flushLogsWithin, never an unbounded flush.

Constructors

Link copied to clipboard
constructor(rootPath: String, streamName: String = "app", diagnosticLoggingEnabled: Boolean = false, fileSystem: FileSystem = FileSystem.SYSTEM, maxFileBytes: Long = DEFAULT_MAX_FILE_BYTES, rolledFiles: Int = DEFAULT_ROLLED_FILES)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val displayPath: String
Link copied to clipboard
val isLoggingEnabled: Boolean

Functions

Link copied to clipboard
suspend fun createLogsSnapshot(destinationPath: String)

Copy every stream into a new private directory. Contention or storage errors are reported to the caller.

Link copied to clipboard
suspend fun deleteLogs()

Delete regular diagnostic files across all streams, retaining preferences, lock file, and unrelated files.

Link copied to clipboard

Drop queued entries after expiry; an already executing filesystem operation is allowed to finish.

Link copied to clipboard
suspend fun flushLogs()

Wait for accepted writes, reporting current storage access failures rather than historical dropped entries.

Link copied to clipboard
suspend fun flushLogsWithin(timeoutMillis: Long): Boolean

Completion barrier with a caller-supplied budget. False means the barrier did not finish in that budget. Attempts a coverage checkpoint without logging recursively. A failed checkpoint leaves older coverage; dropped entries still count as finished. This is not a durability promise.

Link copied to clipboard
open fun isLoggable(tag: String, severity: Severity): Boolean
Link copied to clipboard
open override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?)
Link copied to clipboard
suspend fun setLoggingEnabled(isEnabled: Boolean)

Stop accepting entries immediately, then finish earlier accepted entries even if the caller is cancelled.

Link copied to clipboard
fun updateLoggingEnabled(isEnabled: Boolean)

Refresh host-owned opt-in without IO or waiting for accepted writes.