RFC5424

SyslogPro~ RFC5424

A class to work with RFC5424 formatted syslog messages. The messaging is fully configurable and ANSI foreground * colors can be added. Both ANSI 8 and ANSI 256 color are fully supported. Most APIs will return a promise. These APIs can be used using `then(...)/catch(...)` A Syslog class with a configured Syslog server target can also be used as the input into the formatting classes so that it may run independently. The RFC5424 Syslog logging format is meant to be used as a stream of log data from a service or application. This class is designed to be used in this fashion where new messages are written to the class as needed.

Constructor

new RFC5424(optionsopt)

Source:
Version:
  • 0.0.0
Since:
  • 0.0.0
Construct a new RFC5424 formatted Syslog object with user options
Parameters:
Name Type Attributes Description
options object <optional>
Options object
Properties
Name Type Attributes Default Description
applicationName string <optional>
'NodeJSLogger' Application
hostname string <optional>
os.hostname The name of this server
timestamp boolean <optional>
false Included a Timestamp
timestampUTC boolean <optional>
false RFC standard is for local time
timestampMS boolean <optional>
false Timestamp with ms resolution
timestampTZ boolean <optional>
true Should the timestamp included time zone
includeStructuredData boolean <optional>
false Included any provided structured data
utf8BOM boolean <optional>
true Included the UTF8
color boolean <optional>
false Included the UTF8
extendedColor boolean <optional>
false Included the UTF8 encoding tag with syslog message text
colors object <optional>
User defended colors for severities
Properties
Name Type Attributes Description
emergencyColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
alertColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
criticalColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
errorColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
warningColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
noticeColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
informationalColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
debugColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
server Syslog <optional>
false A Syslog server connection that should be used to send messages directly from this class. @see SyslogPro~Syslog
Requires:
  • module:moment

Requires

  • module:moment

Members

(private) alertColor

Source:

color :boolean

Source:
Type:
  • boolean

(private) constructor__

Source:

(private) criticalColor

Source:

(private) debugColor

Source:

(private) emergencyColor

Source:

includeStructuredData :boolean

Source:
Type:
  • boolean

(private) errorColor

Source:

extendedColor :boolean

Source:
Type:
  • boolean

(private) informationalColor

Source:

(private) noticeColor

Source:

(private) server

Source:

timestamp :boolean

Source:
Type:
  • boolean

timestampMS :boolean

Source:
Type:
  • boolean

timestampTZ :boolean

Source:
Type:
  • boolean

timestampUTC :boolean

Source:
Type:
  • boolean

utf8BOM :boolean

Source:
Type:
  • boolean

(private) warningColor

Source:

Methods

alert(msg) → {Promise}

Source:
Send a syslog message with a severity level of 1 (Alert)
Parameters:
Name Type Description
msg string The alert message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

buildMessage(msg, optionsopt) → {Promise}

Source:
Building a formatted message. Returns a promise with a formatted message
Parameters:
Name Type Attributes Description
msg string The Syslog Message
options object <optional>
Options object
Properties
Name Type Attributes Default Description
severity number <optional>
7 An array of structure
facility number <optional>
23 Facility code to use sending this message
pid string <optional>
'-' The process id of the service sending this message
structuredData Array.<string> <optional>
An array of structure data strings conforming to the IETF/IANA defined SD-IDs or IANA registered SMI Network Management Private Enterprise Code SD-ID conforming to the format [name@ parameter=value]
colorCode number <optional>
36 The ANSI color code to use if message coloration is selected
Throws:
A standard error object
Type
Error
Returns:
A Syslog formatted string according to the selected RFC
Type
Promise

crit(msg) → {Promise}

Source:
Send a syslog message with a severity level of 2 (Critical)
Parameters:
Name Type Description
msg string The critical message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

critical(msg) → {Promise}

Source:
Send a syslog message with a severity level of 2 (Critical)
Parameters:
Name Type Description
msg string The critical message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

debug(msg) → {Promise}

Source:
Send a syslog message with a severity level of 7 (Debug)
Parameters:
Name Type Description
msg string The debug message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

emer(msg) → {Promise}

Source:
Send a syslog message with a severity level of 0 (Emergency)
Parameters:
Name Type Description
msg string The emergency message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

emergency(msg) → {Promise}

Source:
Send a syslog message with a severity level of 0 (Emergency)
Parameters:
Name Type Description
msg string The emergency message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

err(msg) → {Promise}

Source:
Send a syslog message with a severity level of 3 (Error)
Parameters:
Name Type Description
msg string The error message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

error(msg) → {Promise}

Source:
Send a syslog message with a severity level of 3 (Error)
Parameters:
Name Type Description
msg string The error message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

info(msg) → {Promise}

Source:
Send a syslog message with a severity level of 6 (Informational)
Parameters:
Name Type Description
msg string The informational message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

informational(msg) → {Promise}

Source:
Send a syslog message with a severity level of 6 (Informational)
Parameters:
Name Type Description
msg string The informational message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

log(msg) → {Promise}

Source:
Send a syslog message with a severity level of 6 (Informational)
Parameters:
Name Type Description
msg string The informational message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

note(msg) → {Promise}

Source:
Send a syslog message with a severity level of 5 (Notice)
Parameters:
Name Type Description
msg string The notice message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

notice(msg) → {Promise}

Source:
Send a syslog message with a severity level of 5 (Notice)
Parameters:
Name Type Description
msg string The notice message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

send(msg) → {Promise}

Source:
See:
  • SyslogPro~Syslog
send a RFC5424 formatted message. Returns a promise with the formatted message that was sent. If no server connection was defined when the class was created a default Syslog connector will be used.
Parameters:
Name Type Description
msg string The unformatted Syslog message to send
Throws:
A standard error object
Type
Error
Returns:
A Syslog formatted string according to the selected RFC
Type
Promise

setColor()

Source:
Sets the color to be used for messages at a set priority
Parameters:
Name Type Attributes Description
colors.emergencyColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.alertColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.criticalColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.errorColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.warningColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.noticeColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.informationalColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
colors.debugColor string <optional>
A RGB Hex coded color in the form of #FFFFFF or as or the ANSI color code number (30-37 Standard & 0-255 Extended)
Throws:
A standard error object
Type
Error

warn(msg) → {Promise}

Source:
Send a syslog message with a severity level of 4 (Warning)
Parameters:
Name Type Description
msg string The warning message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise

warning(msg) → {Promise}

Source:
Send a syslog message with a severity level of 4 (Warning)
Parameters:
Name Type Description
msg string The warning message to send to the Syslog server
Throws:
- Any bubbled-up error
Type
Error
Returns:
- The formatted syslog message sent to the Syslog server
Type
Promise