@pnp/logging

  • Version 3.3.2
  • Published
  • 17.1 kB
  • 1 dependency
  • MIT license

Install

npm i @pnp/logging
yarn add @pnp/logging
pnpm add @pnp/logging

Overview

pnp - light-weight, subscribable logging framework

Index

Functions

function ConsoleListener

ConsoleListener: (
prefix?: string,
colors?: IConsoleListenerColors
) => ILogListener;

    function FunctionListener

    FunctionListener: (impl: (entry: ILogEntry) => void) => ILogListener;

      function PnPLogging

      PnPLogging: <T>(activeLevel: LogLevel) => (o: T) => T;

        Classes

        class Logger

        class Logger {}
        • Class used to subscribe ILogListener and log messages throughout an application

        property activeLogLevel

        static activeLogLevel: LogLevel;
        • Gets or sets the active log level to apply for log filtering

        property count

        static readonly count: number;
        • Gets the current subscriber count

        method clearSubscribers

        static clearSubscribers: () => ILogListener[];
        • Clears the subscribers collection, returning the collection before modification

        method error

        static error: (err: Error) => void;
        • Logs an error object to the subscribed listeners

          Parameter err

          The error object

        method log

        static log: (entry: ILogEntry) => void;
        • Logs the supplied entry to the subscribed listeners

          Parameter entry

          The message to log

        method subscribe

        static subscribe: (...listeners: ILogListener[]) => void;
        • Adds ILogListener instances to the set of subscribed listeners

          Parameter listeners

          One or more listeners to subscribe to this log

        method write

        static write: (message: string, level?: LogLevel) => void;
        • Writes the supplied string to the subscribed listeners

          Parameter message

          The message to write

          Parameter level

          [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)

        method writeJSON

        static writeJSON: (json: any, level?: LogLevel) => void;
        • Writes the supplied string to the subscribed listeners

          Parameter json

          The json object to stringify and write

          Parameter level

          [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)

        Interfaces

        interface IConsoleListenerColors

        interface IConsoleListenerColors {}
        • Text color options for use in the ConsoleListener All values can be specified as known names, hex values, rgb, or rgba values

        property color

        color?: string;
        • Default text color for all logging levels unless they're specified

        property error

        error?: string;
        • Text color to use for messages with LogLevel.Error

        property info

        info?: string;
        • Text color to use for messages with LogLevel.Info

        property verbose

        verbose?: string;
        • Text color to use for messages with LogLevel.Verbose

        property warning

        warning?: string;
        • Text color to use for messages with LogLevel.Warning

        interface ILogEntry

        interface ILogEntry {}
        • Interface that defines a log entry

        property data

        data?: any;
        • Any associated data that a given logging listener may choose to log or ignore

        property level

        level: LogLevel;
        • The level of information this message represents

        property message

        message: string;
        • The main message to be logged

        interface ILogListener

        interface ILogListener {}
        • Interface that defines a log listener

        method log

        log: (entry: ILogEntry) => void;
        • Any associated data that a given logging listener may choose to log or ignore

          Parameter entry

          The information to be logged

        Enums

        enum LogLevel

        const enum LogLevel {
        Verbose = 0,
        Info = 1,
        Warning = 2,
        Error = 3,
        Off = 99,
        }
        • A set of logging levels

        member Error

        Error = 3

          member Info

          Info = 1

            member Off

            Off = 99

              member Verbose

              Verbose = 0

                member Warning

                Warning = 2

                  Package Files (2)

                  Dependencies (1)

                  Dev Dependencies (0)

                  No dev dependencies.

                  Peer Dependencies (0)

                  No peer dependencies.

                  Badge

                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@pnp/logging.

                  • Markdown
                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@pnp/logging)
                  • HTML
                    <a href="https://www.jsdocs.io/package/@pnp/logging"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>