Scandit Logger

Defined under the namespace Scandit.Datacapture.Core

ScanditLogger
class ScanditLogger

Added in version 8.7.0

Diagnostic logger for the Scandit Data Capture SDK. Every method is static; there is no instance to create and the logger is not attached to a DataCaptureContext.

Logging is off until you raise the level. Records are written to the platform console and kept in an in-memory ring buffer you can read with getRecentLogs() or observe with subscribe().

Privacy. The buffer never leaves your application process. The SDK does not transmit or upload any of it, and nothing reaches Scandit unless you send it yourself. Nothing is written to disk unless your application calls writeLogs(), which writes the buffer to the path you name — a relative path resolves under your application’s own storage — where it stays until you delete it.

Call arguments are recorded, but a fixed redaction floor is applied first: imagery, license keys, device identifiers and captured-document fields are replaced with [redacted], and parser payloads are redacted wholesale. You can add keys to that floor but not remove them — see setAdditionalRedactedArgKeys(). Arguments can be dropped entirely with setLogBridgeArgs(), and error stack traces are omitted unless you ask for them with setLogErrorStacks().

setLevel(level)
static setLevel(level: LogLevel): void

Added in version 8.7.0

Sets the severity threshold. The default is LogLevel.Off, which disables logging entirely. A record also has to pass the category mask — see setCategories().

getLevel()
static getLevel(): LogLevel

Added in version 8.7.0

Returns the current severity threshold.

setCategories(mask)
static setCategories(mask: number): void

Added in version 8.7.0

Sets which LogCategory values are emitted, as a bit mask. The default is Bridge | Lifecycle | Listener, available as DEFAULT_CATEGORIES.

getCategories()
static getCategories(): number

Added in version 8.7.0

Returns the current category mask.

setBufferSize(size)
static setBufferSize(size: number): void

Added in version 8.7.0

Sets how many records the ring buffer holds, at least 1. The default is 1000. Resizing discards the records currently buffered.

getBufferSize()
static getBufferSize(): number

Added in version 8.7.0

Returns the current buffer capacity.

getRecentLogs()
static getRecentLogs(): LogRecord[]

Added in version 8.7.0

Returns the buffered records, oldest first. This is the call to use when attaching logs to a support ticket.

subscribe(cb)
static subscribe(cb: any): any

Added in version 8.7.0

Registers a callback invoked for every record as it is produced, and returns a function that removes it again. A callback that throws is caught and does not disturb the SDK.

static subscribe(cb: (record: LogRecord) => void): () => void
const unsubscribe = ScanditLogger.subscribe(record => {
  console.log(ScanditLogger.format(record));
});

// later
unsubscribe();
clear()
static clear(): void

Added in version 8.7.0

Discards all buffered records.

format(record)
static format(record: LogRecord): string

Added in version 8.7.0

Renders a record as the single-line string the SDK writes to the console.

setLogBridgeArgs(enabled)
static setLogBridgeArgs(enabled: boolean): void

Added in version 8.7.0

Controls whether the arguments of each call are recorded. The default is true, with the redaction floor applied. Pass false to drop arguments entirely, keeping only the method name and the identifiers of the mode or view involved.

getLogBridgeArgs()
static getLogBridgeArgs(): boolean

Added in version 8.7.0

Returns whether call arguments are being recorded.

setLogErrorStacks(enabled)
static setLogErrorStacks(enabled: boolean): void

Added in version 8.7.0

Controls whether a LogRecordError.stack is kept on records that carry an error. The default is false, because a stack trace can contain file paths from your own application binary.

getLogErrorStacks()
static getLogErrorStacks(): boolean

Added in version 8.7.0

Returns whether error stack traces are being kept.

setAdditionalRedactedArgKeys(keys)
static setAdditionalRedactedArgKeys(keys: string[]): void

Added in version 8.7.0

Adds argument keys to the redaction floor, replacing any previously added with this method. The floor itself cannot be removed from, so an empty list restores it rather than disabling redaction. Matching is recursive and also descends into JSON strings, so a key nested inside a serialized payload is caught.

addRedactedArgKey(key)
static addRedactedArgKey(key: string): void

Added in version 8.7.0

Adds one key to the redaction floor, keeping the keys already added.

getRedactedArgKeys()
static getRedactedArgKeys(): Set<string>

Added in version 8.7.0

Returns a copy of the keys currently redacted — the built-in floor plus anything added.

writeLogs(path)
static writeLogs(path: string): Promise<string>

Added in version 8.7.0

Serializes the buffered records to a redacted, human-readable JSON-lines file at path and returns the absolute path written. Missing parent directories are created, and a file already at path is replaced; nothing else in the destination directory is removed.

An app can only write inside its own storage. Pass a path under the app container on iOS (Documents, Library or the temporary directory), or under Context.getFilesDir() or Context.getExternalFilesDir() on Android — anywhere else needs the Storage Access Framework or MediaStore on Android 10 and later. A relative path is resolved against the app’s documents/files directory, which is the portable way to name a destination.

Rejects if debug mode was never enabled, the buffer is empty, the SDK is not initialized yet, or the destination cannot be written; the rejection carries a message saying which, except on Cordova iOS, where only the error code reaches the caller.

Nothing is uploaded — the file is yours to keep, attach to a support mail to support@scandit.com, or hand to your own upload flow.