Birch.kt

console(): Boolean

Returns whether console logging is enabled.

val console = Birch.console

console(console: Boolean)

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

Birch.console = true

customProperties(): Map<String, String>

Returns the custom properties set on the logger.

val properties = Birch.customProperties

customProperties(properties: Map<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 = mapOf("country" to "usa")

debug(): Boolean

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

val debug = Birch.debug

debug(debug: Boolean)

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.

val 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"

init(context: Context, apiKey: String, publicKey: String?, options: Options)

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

ParamDescription
contextAny context will suffice, Birch will get the application context from it.
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.
val apiKey = "your_api_key"
val publicKey = "public_encryption_key"
val options = Options().also {
  it.scrubbers = listOf(PasswordScrubber(), EmailScrubber())
}

Birch.init(this, apiKey, publicKey, options)

level(): Level?

Returns the log level override.

val 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 = Level.TRACE

optOut: Boolean

Returns whether the logger has been opted out of.

val optOut = Birch.optOut

optOut(optOut: Boolean)

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

Birch.optOut = true

remote(): Boolean

Gets whether remote logging is enabled.

val remote = Birch.remote

remote(remote: Boolean)

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

Birch.remote = true

synchronous(): Boolean

Return whether the logger is logging synchronously.

val sync = Birch.synchronous

synchronous(synchronous: Boolean)

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.

val uuid = Birch.uuid