Birch.swift

console(): Bool

Returns whether console logging is enabled.

let console = Birch.console

console(_ console: Bool)

Set whether console logging is enabled. This can be useful in DEBUG builds, otherwise it's better to be false.

Birch.console = true

customProperties(): [String: String]

Returns the custom properties set on the logger.

let properties = Birch.customProperties

customProperties(_ properties: [String: String])

Sets the custom properties on the logger. Properties are persisted and sent with each log message. Limit key name length and number of properties, certain drains have limits imposed by the provider.

Birch.customProperties = ["country": "usa"]

debug(): Bool

Returns whether the logger is in debug mode. Debug logs Birch operations.

let debug = Birch.debug

debug(_ debug: Bool)

Sets the logger to debug mode on/off.

Birch.debug = true

syncConfiguration()

Force the agent to synchronize with the server.

Birch.syncConfiguration()

flush()

Force the agent to upload logs. This will rotate the current log file then queue a job to push logs back to the server.

Birch.flush()

identifier(): String?

Returns the identifier set on the logger. The identifier is sent with each log message.

let identifier = Birch.identifier

identifier(_ identifier: String?)

Sets the identifier for Birch. This is typically set to the user_id but you can set it to anything that you use as an identifier in your system.

Birch.identifier = "your_user_id"

initialize(_ apiKey: String, publicKey: String?, options: Options)

Initializes the logger to start processing and uploading logs. Calling it twice will do nothing.

ParamDescription
apiKeyThe api key for your environment.
publicKeyThe base64 encoded public encryption key, leaving this null will lead to unencrypted logs on disk.
optionsAdditional options to apply to the agent.
let apiKey = "your_api_key"
let publicKey = "public_encryption_key"
let options = Options()
options.scrubbers = [PasswordScrubber(), EmailScrubber()]

Birch.initialize(apiKey, publicKey: publicKey, options: options)

level(): Level?

Returns the log level override.

let level = Birch.level

level(_ level: Level?)

Overrides the logger log level. This value overrides the server so you may only want to use this in DEBUG builds.

Birch.level = .trace

optOut(): Bool

Returns whether the logger has been opted out of.

let optOut = Birch.optOut

optOut(_ optOut: Bool)

Set whether to opt out of logging. This will disable logging and device synchronization.

Birch.optOut = true

remote(): Bool

Gets whether remote logging is enabled.

let remote = Birch.remote

remote(_ remote: Bool)

Set whether remote logging is enabled. This can be useful to limit remote logging in DEBUG builds, otherwise it should be left as true.

Brich.remote = true

synchronous(): Bool

Return whether the logger is logging synchronously.

let sync = Birch.synchronous

synchronous(_ synchronous: Bool)

Set whether the logger should operate synchronously. This can be useful in DEBUG builds, otherwise it should be left as false.

Birch.synchronous = true

uuid(): String

Returns the assigned UUID for this source.

let uuid = Birch.uuid