new Connection()
Extends
- EventEmitter
Members
-
nullablecommitBuffer
-
Default value for the
commitfield -
LEVELnumber
-
Standard level values
Properties:
Name Type Default Description DEBUGnumber 0 INFOnumber 1 WARNnumber 2 ERRORnumber 3 FATALnumber 4 -
RELEVANCEnumber
-
Possible relevance values
Properties:
Name Type Default Description LOWnumber 0 NORMALnumber 1 HIGHnumber 2 -
relevanceConnection#RELEVANCE
-
Default value for relevance (initial value is NORMAL)
-
STATEnumber
-
Ready state values for Connection#state
Properties:
Name Type Default Description UNINITIALIZEDnumber 0 CONNECTINGnumber 1 CONNECTEDnumber 2 CLOSEDnumber 4 -
readonlystateConnection#STATE
-
The connection readiness. If the connection is not ready yet, all commands will be buffered and executed when appropriate
-
readonlyuserstring
-
User name, set after Connection#connect() is called
Methods
-
bindName(name){Logger}
Connection.js, line 336 -
Use it to ease logging multiple times with the same
namefield. Logs created this way will have thetimefield set as the elapsed time (in ms) between this call and subsequent calls to Logger methodsName Type Description namestring - Deprecated
- replaced by Connection#getLogger
Returns:
Type Description Logger -
close(callback)
Connection.js, line 171 -
Close the connection
Name Type Description callbackfunction optional added as listener to Connection#event:close
-
connect(user, password, socketOptionsOrUrl)
Connection.js, line 142 -
Start the connection with the log sink server. To connect to a server using TLS, set
socketOptions.secureastrueName Type Description userstring account name in the server
passwordstring base 64 encoded, like
'u4zJEF16B5UAvalmp+oY0QdSSvhqMBxj64WYlK7Omio='socketOptionsOrUrlObject | string In node: an object passed to net.connect or tls.connect, if
socketOptions.secureistrue. For browser: the websocket url as a string, like 'wss://example.com:8017/' -
debug(name, message, extra)
Connection.js, line 269 -
Simpler way for Connection#sendLog with
levelset as DEBUGName Type Description namestring messagestring | Error optional extra* optional any JSON-compatible value
-
disable()
Connection.js, line 193 -
Disables the connection, making it ignore all logs and always failing in stream() and query(). This is useful for a test environment, for example, because otherwise the internal buffer would grow unboundedly
-
error(name, message, extra)
Connection.js, line 299 -
Simpler way for Connection#sendLog with
levelset as ERRORName Type Description namestring messagestring | Error optional extra* optional any JSON-compatible value
-
fatal(name, message, extra)
Connection.js, line 309 -
Simpler way for Connection#sendLog with
levelset as FATALName Type Description namestring messagestring | Error optional extra* optional any JSON-compatible value
-
getLogger(name, relevance, basicExtra){Logger}
Connection.js, line 324 -
Use it to ease logging multiple times with the same
name,relevanceand someextrakeys Logs created this way will have thetimefield set as the elapsed time (in ms) between this call and subsequent calls to Logger methods. Keys on thebasicExtraparameter will be assigned to the extra object passed when calling Logger methods.Name Type Default Description namestring relevanceConnection#RELEVANCE Connection#relevance optional basicExtraObject optional Returns:
Type Description Logger -
getPermissions(callback)
Connection.js, line 426 -
Get the list of available permissions for the current user The current user name will be included in the answer and will always be the first element of the array
Name Type Description callbackfunction cb(err,permissions)
-
info(name, message, extra)
Connection.js, line 279 -
Simpler way for Connection#sendLog with
levelset as INFOName Type Description namestring messagestring | Error optional extra* optional any JSON-compatible value
-
query(query, options, callback)
Connection.js, line 396 -
Query log data
Name Type Default Description queryObject {} optional Name Type Default Description dateObject optional Name Type Default Description minDate yesterday optional maxDate optional originstring Connection#user optional relevanceConnection#RELEVANCE Connection#relevance optional namestring optional nameRegexRegExp optional ignored if
query.nameis givenlevelConnection~Range optional timeConnection~Range optional messagestring optional messageRegexRegExp optional ignored if
query.messageis givencommitBuffer optional extra* optional follows mongodb query syntax, see official docs
optionsObject {} optional Name Type Default Description includeExtraboolean false optional if false (default), the
extrafield is not receivedlimitnumber 100 optional skipnumber 0 optional sortstring 'date' optional same syntax as mongoose, example: 'date -time'
callbackfunction fn(err, logs:Array
) -
sendLog(data, callback)
Connection.js, line 216 -
The low level way to send log data to the server. Most of times, Connection#info (and its family) and Connection#bindName will be much more useful.
Name Type Description dataObject Name Type Default Description namestring levelConnection#LEVEL dateDate new Date optional relevanceConnection#RELEVANCE Connection#relevance optional commitBuffer Connection#commit optional timenumber optional messagestring optional extra* optional any JSON-compatible data (like number, string, boolean, null, array and object)
callbackfunction optional optional cb(err). If not present, the log is sent in a fire-and-forget fashion, provinding better latency and throughput
-
stream(filter, includeExtra, callback)
Connection.js, line 356 -
Create a log stream. This is done asynchronously: the stream will be passed to the callback
Name Type Default Description filterObject {} optional filter the stream
Name Type Default Description originstring Connection#user optional the user must have permission to read from it
namestring optional nameRegexRegExp optional ignored if
filter.nameis givenlevelConnection~Range optional see standard values in Connection#LEVEL
relevanceConnection~Range optional see possible values in Connection#RELEVANCCE
timeConnection~Range optional messagestring optional messageRegexRegExp optional ignored if
filter.messageis givencommitBuffer optional includeExtraboolean false optional if false (default), log's
extrafield won't be received, improving performancecallbackfunction cb(err, logStream:LogStream)
-
warn(name, message, extra)
Connection.js, line 289 -
Simpler way for Connection#sendLog with
levelset as WARNName Type Description namestring messagestring | Error optional extra* optional any JSON-compatible value
Type Definitions
-
LogObject
-
Properties:
Name Type Argument Description originstring dateDate namestring levelConnection#LEVEL relevanceConnection#RELEVANCE timenumber <optional>
messagestring <optional>
commitBuffer <optional>
extra* <optional>
-
RangeObject
-
Properties:
Name Type Argument Description minnumber <optional>
inclusive
maxnumber <optional>
inclusive
Events
-
close
Connection.js, line 26 -
Emited when the connection is closed and no more activity will happen. Connection#state is CLOSED
-
connect
Connection.js, line 15 -
Fired when the connection is ready. Connection#state is CONNECTED
-
connecting
Connection.js, line 9 -
Fired when Connection#connect() is called. Connection#state is CONNECTING
-
error
Connection.js, line 21 -
Type:
- Error