iamqp
Version:
RabbitMQ wrapper for NodeJS with several produce(reply)/consume scenarios
801 lines (238 loc) • 14.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>ConsoleLogger - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Common.html">Common</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_commonPublishPreparations">_commonPublishPreparations</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_emitAndDispatchError">_emitAndDispatchError</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_logData">_logData</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_messageDispatcherWrapper">_messageDispatcherWrapper</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_parseConsumedMessage">_parseConsumedMessage</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_preparePublishingMessage">_preparePublishingMessage</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#closeConnection">closeConnection</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#getEventer">getEventer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#isReady">isReady</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#openConnection">openConnection</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#toString">toString</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="ConsoleLogger.html">ConsoleLogger</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#error">error</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#info">info</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#log">log</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#warn">warn</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="FanoutConsumer.html">FanoutConsumer</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="FanoutProducer.html">FanoutProducer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="FanoutProducer.html#fanout">fanout</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="PlainConsumer.html">PlainConsumer</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="PlainProducer.html">PlainProducer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="PlainProducer.html#publish">publish</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="RpcClient.html">RpcClient</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="RpcClient.html#callRemote">callRemote</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="RpcServer.html">RpcServer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="RpcServer.html#respond">respond</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="UUIDv4.html">UUIDv4</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="UUIDv4.html#generate">generate</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li>
</nav>
<div id="main">
<h1 class="page-title">ConsoleLogger</h1>
<section>
<header>
<h2>
ConsoleLogger
</h2>
<div class="class-description"><p>Interface some coloured terminal logging and syslog on Linux.</p>
<p>Provides four types of logs:</p>
<ul>
<li><b>info (blue)</b> - operational messages that require no action</li>
<li><b>log (yellow)</b> - useful information (in terms of debugging for instance)</li>
<li><b>warn (magenta)</b> - do not stops the execution but have the potential to</li>
<li><b>error (red)</b> - errors that are stopping some operational flow</li>
</ul>
<p>Provides an option to use <a href="https://en.wikipedia.org/wiki/Syslog">syslog</a> - print to systems log.
This was tested on <code>Ubuntu 16.04</code>.
To enable this, open <code>/etc/rsyslog.conf</code> and enable <i>UDP</i> on port <i>514</i>.
This is usually just commented and needs uncommenting:</p>
<pre>
# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")
</pre>
<p>... and restart the service with <code>./etc/init.d/rsyslog restart</code>.
The logs should appear in <code>/var/log/syslog</code>.</p>
<p>To control the logging, use environmental variables:</p>
<ul>
<li><code>DBTRC_SYSLOG_F</code> set to <code>OK</code> to enable syslog logging
<pre>
DBTRC_SYSLOG_F=OK node ...
</pre>
</li>
<li><code>DBTRC_TERM_F</code> set to <code>OK</code> to enable terminal logging
<pre>
DBTRC_TERM_F=OK node ...
</pre>
</li>
</ul></div>
</header>
<article>
<div class="container-overview">
<div class="section-method">
<h2>Constructor</h2>
<h4 class="name" id="ConsoleLogger"><span class="type-signature"></span>new ConsoleLogger<span class="signature">(moduleName)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="console_logger.js.html">console_logger.js</a>, <a href="console_logger.js.html#line45">line 45</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>moduleName</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="description last">
<p>the name of the module - something to represent the instance</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 class="subsection-title">Methods</h3>
<div class="section-method">
<h4 class="name" id="error"><span class="type-signature"></span>error<span class="signature">(logMessage)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Produce an error message.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="console_logger.js.html">console_logger.js</a>, <a href="console_logger.js.html#line98">line 98</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>logMessage</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
</div>
<div class="section-method">
<h4 class="name" id="info"><span class="type-signature"></span>info<span class="signature">(logMessage)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Produce a info message.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="console_logger.js.html">console_logger.js</a>, <a href="console_logger.js.html#line106">line 106</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>logMessage</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
</div>
<div class="section-method">
<h4 class="name" id="log"><span class="type-signature"></span>log<span class="signature">(logMessage)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Produce a log message.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="console_logger.js.html">console_logger.js</a>, <a href="console_logger.js.html#line122">line 122</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>logMessage</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
</div>
<div class="section-method">
<h4 class="name" id="warn"><span class="type-signature"></span>warn<span class="signature">(logMessage)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Produce a warning message.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="console_logger.js.html">console_logger.js</a>, <a href="console_logger.js.html#line114">line 114</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>logMessage</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> on Sun Aug 04 2019 22:10:47 GMT+0200 (Central European Summer Time) using the Minami theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>