Logging
The Descope backend SDKs can emit log messages to help you diagnose failed API calls, session validation errors, and configuration problems.
Support differs by language, and the SDKs do not share a common shape. Some take a log level, some take a logger object you supply.
| SDK | What you set | Log levels |
|---|---|---|
| Node.js | A logger object | None, so you filter inside the logger you supply |
| Go | LogLevel, and optionally a Logger of your own | logger.LogNone, logger.LogInfoLevel, and logger.LogDebugLevel |
| Ruby | log_level, and optionally a logger of your own | debug, info, warn, error, fatal, and unknown |
| PHP | debug to true or false | None |
Enabling a Logger
The Node.js SDK takes a logger object rather than a log level. Pass it alongside projectId:
import DescopeClient from '@descope/node-sdk';
const descopeClient = DescopeClient({
projectId: '__ProjectID__',
logger: console,
});During development you can pass console directly. To route messages into your own logging service, supply an object with debug, log, warn, and error methods:
const logger = {
debug: (message, ...args) => myLogger.debug(message, ...args),
log: (message, ...args) => myLogger.info(message, ...args),
warn: (message, ...args) => myLogger.warn(message, ...args),
error: (message, ...args) => myLogger.error(message, ...args),
};
const descopeClient = DescopeClient({
projectId: '__ProjectID__',
logger,
});All four methods are required, which is why passing console works. The SDK calls error for failures, log for informational messages, and warn for non-fatal problems. Messages are emitted for session validation failures, refresh token validation failures, access key exchange failures, public key parsing errors, and license handshake problems.