TreeINFO-For-M365 documentation
    Preparing search index...

    Logs messages to the console and Application Insights. Optionally shows a toast with the logged message in the UI.

    // log critical error
    tisa.log.critical("some critical error message");

    // log error
    tisa.log.error("some error message");
    tisa.log.error("some error message", { showToast: true }); // show toast with the error message in the UI

    // log warning message
    tisa.log.warn("some warning message");

    // log info message
    tisa.log.info("some info message");
    tisa.log.info("some info message", { showToast: true }); // show toast with the info message in the UI

    // log debug message
    tisa.log.debug("some debug message");

    // log trace message
    tisa.log.trace("some trace message");
    Index

    Properties

    disableWriteConsole: boolean = false

    If true, no messages will be written to the console. This is useful in production to avoid logging sensitive information to the console.

    // disable writing to the console
    tisa.log.disableWriteConsole = true; // stopped writing to the console
    tisa.log.info("some info message"); // message will not be written to the console
    tisa.log.disableWriteConsole = false; // restored writing to the console

    Methods

    • Logs the message as critical.

      Parameters

      • error: string | Error

        the error to log; can be a string or an error object

      • options: LogErrorOptions = {}

      Returns void

      // log a critical error message
      tisa.log.critical("some critical error message");

      // log a critical error message and show toast
      tisa.log.critical("some critical error message", { showToast: true });

      // log a critical error message, show toast, pass a unique error id, add custom properties, add console params and pass the error object
      tisa.log.critical("some critical error message", {
      showToast: true,
      id: "1234567890",
      customProperties: { customProperty: "custom value" },
      consoleParams: ["some console param"],
      error: new Error("some error")
      });

      // log an error object as critical
      tisa.log.critical(new Error("some critical error message"));
    • Logs the message as debug.

      Parameters

      • message: string

        the message to log

      • options: LogOptions = {}

      Returns void

      // log a debug message
      tisa.log.debug("some debug message");
    • Logs the message as error.

      Parameters

      • error: string | Error

        the error to log; can be a string or an error object

      • options: LogErrorOptions = {}

      Returns void

      // log an error message
      tisa.log.error("some error message");

      // log an error message and show toast
      tisa.log.error("some error message", { showToast: true });

      // log an error message, show toast, pass a unique error id, add custom properties, add console params and pass the error object
      tisa.log.error("some error message", {
      showToast: true,
      id: "1234567890",
      customProperties: { customProperty: "custom value" },
      consoleParams: ["some console param"],
      error: new Error("some error")
      });

      // log an error object as error
      tisa.log.error(new Error("some error"));
    • Logs the message as information.

      Parameters

      • message: string

        the message to log

      • options: LogOptions = {}

      Returns void

      // log an info message
      tisa.log.info("some info message");

      // log an info message and show toast
      tisa.log.info("some info message", { showToast: true });
    • Logs the message as trace.

      Parameters

      • message: string

        the message to log

      • options: LogOptions = {}

      Returns void

      // log a trace message
      tisa.log.trace("some trace message");
    • Logs the message as warning.

      Parameters

      • message: string

        the message to log

      • options: LogOptions = {}

      Returns void

      // log a warning message with a string
      tisa.log.warn("some warning message");

      // log a warning message with a string and show toast
      tisa.log.warn("some warning message", { showToast: true });

      // log a warning message with an error object
      tisa.log.warn("some warning message", { showToast: true, error: new Error("some error") });