Birch.ts

getConsole(): Promise<boolean>

Returns whether console logging is enabled.

let allowConsole = await Birch.getConsole();

setConsole(value: boolean)

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

Birch.setConsole(true);

getCustomProperties(): Promise<Record<string, string>>

Returns the custom properties set on the logger.

const customProperties = await Birch.getCustomProperties();

setCustomProperties(value: Record<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.setCustomProperties({});

getDebug(): Promise<boolean>

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

const debug = await Birch.getDebug();

setDebug(value: boolean)

Sets the logger to debug mode on/off.

Birch.setDebug(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();

getIdentifier(): Promise<string | undefined>

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

const identifier = await Birch.getIdentifier();

setIdentifier(value: string | undefined)

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.setIdentifier("your_user_id");

init(apiKey: string, publicKey: string | undefined, 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 undefined will lead to unencrypted logs on disk.
optionsAdditional options to apply to the agent.
import Birch, { Level } from 'react-native-birch';

const apiKey = "your_api_key";
const publicKey = "public_encryption_key"
const options = {
  defaultLevel: Level.Trace
}

Birch.init(apiKey, publicKey, options);

getLevel(): Promise<Level | undefined>

Returns the log level override.

const level = await Birch.getLevel();

setLevel(value: Level | undefined)

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

Birch.setLevel(Level.trace);

getOptOut(): Promise<boolean>

Returns whether the logger has been opted out of.

const optOut = await Birch.getOptOut();

setOptOut(value: boolean)

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

Birch.setOptOut(true);

getRemote(): Promise<boolean>

Gets whether remote logging is enabled.

const remote = await Birch.getRemote();

setRemote(value: 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.

Brich.setRemote(true);

getSynchronous(): Promise<boolean>

Return whether the logger is logging synchronously.

const sync = await Birch.getSynchronous();

setSynchronous(value: boolean)

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

Birch.setSynchronous(true);

getUuid(): Promise<string>

Returns the assigned UUID for this source.

const uuid = await Birch.getUuid();