Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
3 changed files with 36 additions and 0 deletions
Showing only changes of commit 1b51b50185 - Show all commits

13
lib/log/Readme.md Normal file
View File

@ -0,0 +1,13 @@
<a name="createLog"></a>
## createLog(label, filename) ⇒ <code>object</code>
createLog() - Returns a winston logger configured to service
**Kind**: global function
**Returns**: <code>object</code> - Winston logger
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| label | <code>string</code> | | Label appearing on logger |
| filename | <code>string</code> | <code>null</code> | Optional file to write log to |

22
lib/log/index.js Normal file
View File

@ -0,0 +1,22 @@
'use strict'
const winston = require('winston')
/**
* createLog() - Returns a winston logger configured to service
*
* @param {string} label Label appearing on logger
* @param {string} filename Optional file to write log to
* @returns {object} Winston logger
*/
function createLog (label, filename = null) {
const transports = [ new (winston.transports.Console)({ label : label }) ]
if (filename !== null) {
transports.push( new (winston.transports.File)({ label : label, filename : filename }) )
}
return new (winston.Logger)({
transports: transports
})
}
module.exports = createLog

View File

@ -9,6 +9,7 @@ const refresh = '/sbin/ifdown wlan0 && /sbin/ifup --force wlan0'
const iwlist = '/sbin/iwlist wlan0 scanning | grep "ESSID:"'
const iwgetid = '/sbin/iwgetid'
const log = require('../log')('wifi')
const exec = require('child_process').exec
const fs = require('fs')