Skip to main content

Logging

This module uses Winston for logging. You can customize the logging or even add your own transports using the APIs below.

Log levels#

To set the amount of information that is logged, you can set the logLevel constructor param to one of the following:

  • CollabServer.LogLevels.DEBUG maximum amount of logging. This will log all information including all queries that are executed.
  • CollabServer.LogLevels.INFO This will log information about server status including server started
  • CollabServer.LogLevels.WARN This will log all warnings to the console. Queries will not be logged.
  • CollabServer.LogLevels.ERROR Only error messages are logged
  • CollabServer.LogLevels.NONE Nothing is logged (only uncaught exceptions)

The default log level is INFO.

Example

import CollabServer from "@pdftron/collab-server";
const server = new CollabServer({
logLevel: CollabServer.LogLevels.WARN,
});

Filter logs by tag#

To filter logs by tag, you can set the filterLogsByTag option to one or more of the following:

  • LogTags.ENTITY - Logged any time a new entity is created
  • LogTags.MUTATION - Logged any time a database mutation is performed
  • LogTags.RESPONSE - Logged any time data is returned from the database
  • LogTags.AUTH - Logs information about user authentication
  • LogTags.CACHE - Logs information about caching
  • LogTags.CONNECTED_USERS - Logs information about users who are connected to the user
  • LogTags.SCROLL_SYNC - Logs information about scroll sync sessions
  • LogTags.ANNOTATION_SYNC - Logs information about external annotation syncing
  • LogTags.PERMISSIONS - Logs information about permissions and permission checks
  • LogTags.PERMISSION_CACHE - Logs information about the permission check cache
  • LogTags.BATCH - Logs information about batch writes
  • LogTags.REAL_TIME - Logs information about real time events that are sent
  • LogTags.UNREAD - Logs information about the unread status of annotations
  • LogTags.CLIENT - (Server only) Logs messages sent from the client to the server
  • LogTags.ANNOTATIONS - Logs information about annotation actions (add, edit, delete)

Example

import CollabServer from "@pdftron/collab-server";
const server = new CollabServer({
filterLogsByTag: CollabServer.LogTags.MUTATION,
// or set multiple by passing an array
filterLogsByTag: [
CollabServer.LogTags.MUTATION,
CollabServer.LogTags.ANNOTATIONS,
]
});

Transports#

A logging transport is essentially the destination for a log. By default, all logs go to the console, but you can extend this by adding your own transports.

To add your own transports, pass an array of transports to the logTransports option in the constructor.

Example

import CollabServer from "@pdftron/collab-server";
import winston from "winston";
const server = new CollabServer({
logLevel: CollabServer.LogLevels.WARN,
transports: [
new winston.transports.File({ filename: "combined.log", level: "error" }),
],
});