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. While the level is above Off the SDK also stores the records in your application’s private storage, from where writeLogs() exports them to a file that 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. The floor cannot be changed, and error stack traces are never recorded.

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.

getLevel()
static getLevel(): LogLevel

Added in version 8.7.0

Returns the current severity threshold.

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(): Promise<void>

Added in version 8.7.0

Discards all buffered records.

Also deletes the log files the SDK stored on the device while the level was above Off. The returned promise resolves once they are gone.

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.

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

Added in version 8.7.0

Writes the records the SDK stored on the device, oldest first, as a redacted, human-readable JSON-lines file with a one-line header in front, and returns the absolute path written. Records from the native side and from the JavaScript side are both included.

Without path the file is scandit-debug-log.jsonl in the application’s cache directory, replaced on every call. With a path, missing parent directories are created and a file already there 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 no record is stored (call setLevel() first), 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.