bs-logger

  • Version 0.2.6
  • Published
  • 47.8 kB
  • 1 dependency
  • MIT license

Install

npm i bs-logger
yarn add bs-logger
pnpm add bs-logger

Overview

Bare simple logger for NodeJS

Index

Variables

variable DEFAULT_LOG_TARGET

const DEFAULT_LOG_TARGET: string;

    variable logger

    const logger: Logger;

      variable LogLevels

      const LogLevels: {
      trace: number;
      debug: number;
      info: number;
      warn: number;
      error: number;
      fatal: number;
      readonly lower: number;
      readonly higher: number;
      };

        variable rootLogger

        const rootLogger: Logger;

          Functions

          function createLogger

          createLogger: ({
          context: baseContext,
          targets: logTargets,
          translate: logTranslator,
          }?: CreateLoggerOptions) => Logger;

            function lastSequenceNumber

            lastSequenceNumber: () => number;

              function logLevelNameFor

              logLevelNameFor: (level?: number | undefined) => string;

                function parseLogLevel

                parseLogLevel: (level: string | number) => number | undefined;

                  function parseLogTargets

                  parseLogTargets: (targetString?: string | undefined) => LogTarget[];

                    function registerLogFormatter

                    registerLogFormatter: (name: string, format: LogMessageFormatter) => void;

                      function resetLogFormatters

                      resetLogFormatters: () => void;

                        function resetSequence

                        resetSequence: (next?: number) => void;

                          function setup

                          setup: (factory?: () => Logger) => void;

                            Interfaces

                            interface LogContext

                            interface LogContext {}

                              property [LogContexts.application]

                              [LogContexts.application]?: string;

                                property [LogContexts.hostname]

                                [LogContexts.hostname]?: string;

                                  property [LogContexts.logLevel]

                                  [LogContexts.logLevel]?: number;

                                    property [LogContexts.namespace]

                                    [LogContexts.namespace]?: string;

                                      property [LogContexts.package]

                                      [LogContexts.package]?: string;

                                        index signature

                                        [key: string]: any;

                                          interface Logger

                                          interface Logger extends LogMethod {}

                                            property child

                                            child: LogChildMethod;

                                              property debug

                                              debug: LogMethod;

                                                property error

                                                error: LogMethod;

                                                  property fatal

                                                  fatal: LogMethod;

                                                    property info

                                                    info: LogMethod;

                                                      property trace

                                                      trace: LogMethod;

                                                        property warn

                                                        warn: LogMethod;

                                                          property wrap

                                                          wrap: LogWrapMethod;

                                                            interface LogMessage

                                                            interface LogMessage {}

                                                              property context

                                                              context: LogContext;

                                                                property message

                                                                message: string;

                                                                  property sequence

                                                                  sequence: number;

                                                                    property time

                                                                    time: number;

                                                                      interface LogMethod

                                                                      interface LogMethod {}

                                                                        property isEmptyFunction

                                                                        isEmptyFunction?: boolean;

                                                                          call signature

                                                                          (message: string, ...args: any[]): void;

                                                                            call signature

                                                                            (context: LogContext, message: string, ...args: any[]): void;

                                                                              interface LogTarget

                                                                              interface LogTarget {}

                                                                                property format

                                                                                format: LogMessageFormatter;

                                                                                  property minLevel

                                                                                  minLevel: number;

                                                                                    property stream

                                                                                    stream: Writable;

                                                                                      Enums

                                                                                      enum LogContexts

                                                                                      enum LogContexts {
                                                                                      application = 'application',
                                                                                      hostname = 'hostname',
                                                                                      logLevel = 'logLevel',
                                                                                      namespace = 'namespace',
                                                                                      package = 'package',
                                                                                      }

                                                                                        member application

                                                                                        application = 'application'

                                                                                          member hostname

                                                                                          hostname = 'hostname'

                                                                                            member logLevel

                                                                                            logLevel = 'logLevel'

                                                                                              member namespace

                                                                                              namespace = 'namespace'

                                                                                                member package

                                                                                                package = 'package'

                                                                                                  Type Aliases

                                                                                                  type LogLevelName

                                                                                                  type LogLevelName = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';

                                                                                                    type LogMessageFormatter

                                                                                                    type LogMessageFormatter = (msg: LogMessage) => string;

                                                                                                      type LogMessageTranslator

                                                                                                      type LogMessageTranslator = (msg: LogMessage) => LogMessage;

                                                                                                        Namespaces

                                                                                                        namespace testing

                                                                                                        module 'dist/testing/index.d.ts' {}

                                                                                                          function createLoggerMock

                                                                                                          createLoggerMock: (
                                                                                                          options?: CreateLoggerOptions | undefined,
                                                                                                          target?: LogTargetMock
                                                                                                          ) => LoggerMock;

                                                                                                            function extendArray

                                                                                                            extendArray: <T>(array: T[]) => ExtendedArray<T>;

                                                                                                              function setup

                                                                                                              setup: (target?: LogTargetMock) => void;

                                                                                                                class LogTargetMock

                                                                                                                class LogTargetMock implements LogTarget {}

                                                                                                                  constructor

                                                                                                                  constructor(minLevel?: number);

                                                                                                                    property lines

                                                                                                                    readonly lines: ExtendedArray<string> & LogLevelMap<ExtendedArray<string>>;

                                                                                                                      property messages

                                                                                                                      readonly messages: ExtendedArray<LogMessage> &
                                                                                                                      LogLevelMap<ExtendedArray<LogMessage>>;

                                                                                                                        property minLevel

                                                                                                                        minLevel: number;

                                                                                                                          property stream

                                                                                                                          readonly stream: any;

                                                                                                                            method clear

                                                                                                                            clear: () => void;

                                                                                                                              method filteredLines

                                                                                                                              filteredLines: {
                                                                                                                              (level: number, untilLevel?: number): ExtendedArray<string>;
                                                                                                                              (level: null): ExtendedArray<string>;
                                                                                                                              };

                                                                                                                                method filteredMessages

                                                                                                                                filteredMessages: {
                                                                                                                                (level: number, untilLevel?: number): ExtendedArray<LogMessage>;
                                                                                                                                (level: null): ExtendedArray<LogMessage>;
                                                                                                                                };

                                                                                                                                  method format

                                                                                                                                  format: (msg: LogMessage) => string;

                                                                                                                                    interface ExtendedArray

                                                                                                                                    interface ExtendedArray<T> extends Array<T> {}

                                                                                                                                      property last

                                                                                                                                      readonly last: T | undefined;

                                                                                                                                        interface LoggerMock

                                                                                                                                        interface LoggerMock extends Logger {}

                                                                                                                                          property target

                                                                                                                                          readonly target: LogTargetMock;

                                                                                                                                            Package Files (9)

                                                                                                                                            Dependencies (1)

                                                                                                                                            Dev Dependencies (15)

                                                                                                                                            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/bs-logger.

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