mirror of
https://github.com/vale981/doccam-pi
synced 2025-03-05 17:31:39 -05:00
130 lines
3.5 KiB
HTML
130 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: src/logger.js</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="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: src/logger.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>///////////////////////////////////////////////////////////////////////////////
|
|
// Winston Logger Wrapper with Custom Colors and Transports //
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
let winston = require('winston');
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// Declarations //
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Object oriented `this`.
|
|
let self = false;
|
|
|
|
// Custom log levels.
|
|
const customLevels = {
|
|
levels: {
|
|
normal: 0,
|
|
info: 1,
|
|
warning: 2,
|
|
danger: 3,
|
|
success: 4
|
|
},
|
|
colors: {
|
|
normal: 'white',
|
|
info: 'blue',
|
|
warning: 'orange',
|
|
danger: 'red',
|
|
success: 'green'
|
|
}
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// Code //
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
* Monkey Patching.
|
|
*/
|
|
|
|
|
|
/**
|
|
* Calls the logging function with arguments, if the node enviroment isn't in production mode.
|
|
*/
|
|
winston.Logger.prototype.dbgmsg = function() {
|
|
if (process.env.NODE_ENV !== 'production')
|
|
this.log.apply(undefined, arguments);
|
|
};
|
|
|
|
// Set the Colors
|
|
winston.addColors(customLevels.colors);
|
|
|
|
let logger = (function() {
|
|
if(!self)
|
|
self = new(winston.Logger)({
|
|
levels: customLevels.levels,
|
|
transports: [
|
|
new(winston.transports.Console)({
|
|
level: 'success'
|
|
}),
|
|
new(winston.transports.File)({
|
|
filename: __dirname + '/process.log',
|
|
colorize: true,
|
|
timestamp: true,
|
|
level: 'success',
|
|
json: true,
|
|
maxsize: 500000,
|
|
maxFiles: 10
|
|
})
|
|
]
|
|
});
|
|
|
|
return self;
|
|
})();
|
|
|
|
logger.importance = ['normal', 'info', 'warning', 'danger', 'success'];
|
|
|
|
// Export the Logger
|
|
module.exports = logger;
|
|
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|