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 database status including database connected
  • CollabDatabase.LogLevels.WARN This will log all warnings to the console. Queries will not be logged.
  • CollabDatabase.LogLevels.ERROR Only error messages are logged
  • CollabDatabase.LogLevels.NONE Nothing is logged (only uncaught exceptions)

The default log level is INFO.

Example

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

Transports#

A logging transport is esentially 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 CollabDatabase from "@pdftron/collab-db-postgresql";
import winston from "winston";
const db = new CollabDatabase({
logLevel: CollabDatabase.LogLevels.WARN,
transports: [
new winston.transports.File({ filename: "combined.log", level: "error" }),
],
});