logMessages

Delivers everything the SDK logs: problems it worked around without failing the operation. The SDK never prints to the browser console; subscribe to receive the messages. See Error handling and logging for the throw-versus-log rules.

const unsubscribe = logMessages.on('message', (logMessage) => { ... })

Each LogMessage carries:

FieldMeaning
levelThe severity: LogLevel.Debug, Info, Warning, or Error. The values are numeric and ordered, so a threshold is a comparison.
reasonThe problem category: a LogReason member (see below).
messageA static string. Variable details never appear in it, so messages group cleanly in log aggregation. A License message is the exception: its text comes from the license service.
dataThe variable details, when any.
stackThe call stack at the point the message was emitted, when available.

Reasons

LogReasonLevelMeaning
DocumentFormatIssueInfoThe PDF content breaks the PDF specification; the SDK handled it.
NotSupportedWarningThe document uses a PDF feature the SDK doesn't support yet.
PerformanceIssueWarningSomething works correctly but wastefully and is worth investigating.
InvalidInputErrorYour code passed input the SDK couldn't use, such as an incompatible combination of arguments.
UnexpectedErrorErrorAn internal error unrelated to the document content.
LicenseAnyA notice from the license service, such as an exceeded quota, reported after a document opens. The service picks the level.

Example

import { logMessages, LogLevel } from '@sdk-pdf/react'

const unsubscribe = logMessages.on('message', (logMessage) => {
  if (logMessage.level >= LogLevel.Warning) {
    reportToMonitoring(logMessage.message, logMessage.data)
  }
})

On this page