1.4.0 • Published 2 years ago

@mangar2/logfilter v1.4.0

Weekly downloads
8
License
LGPL-3.0-or-later
Repository
github
Last release
2 years ago

Abstract

Filters logs by a topic string and prints them to console

Contents

Meta

Filelogfilter.js
AbstractFilters logs by a topic string and prints them to console
AuthorVolker Böhm
CopyrightCopyright ( c ) 2020 Volker Böhm
LicenseThis software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3 . It is furnished "as is" , without any support , and with no warranty , express or implied , as to its usefulness for any purpose .

Type definitions

LogPattern {Object}

NameTypeDescription
patternstringlog topic pattern
modulestringmodule to log , "send" , "receive" or "all" ( for all modules )
levelnumberlog level for the pattern

Class LogFilter

new LogFilter()

Provides a simple filter for logging topic based messages

Example

const logfilter = new LogFilter()
logfilter.changePattern([{ topic: 'input/%', module: 'receive', level: 1 }])
logfilter.condLogMessage('receive', new Message('hello world', 1), 1)

LogFilter Methods

changePattern

changePattern (patternList)

Replaces the log filter patterns , deleting the current patterns and replace them with the new patterns

changePattern Parameters
NameType
patternListArray.<LogPattern>
changePattern throws
TypeDescription
| error , if the parameter is badly formatted

condLogMessage

condLogMessage (moduleStr, message, qos, dup, serviceName)

Logs a message

condLogMessage Parameters
NameTypeAttributeDescription
moduleStrstringname of the "module" for logging
messageMessagemessage structure
qosnumberquality of service of message delivery
dupboolean, numberduplicate flag ( true/false , 0/1 )
serviceNamestringoptionalname of the service logging

getLogLevel

getLogLevel (module, topic) => {undefined, number}

Gets the log level

getLogLevel Parameters
NameTypeDescription
modulestringname of the module to check for
topicstringtopic to check
getLogLevel returns
TypeDescription
undefined, numberreturns a log level or undefine , if logging is false