/server.js |
@@ -54,6 +54,8 @@ |
.argv |
|
// Create various logging mechanisms. |
// RFC5424 - { emerg: 0, alert: 1, crit: 2, error: 3, warning: 4, notice: 5, info: 6, debug: 7 } |
winston.setLevels(winston.config.syslog.levels); |
const log = new winston.Logger({ |
transports: [ |
new winston.transports.File({ |
@@ -92,18 +94,24 @@ |
http.createServer( |
// authentication, |
(request, response) => |
handler.process(config, request, response, root, (error, level) => { |
switch (level) { |
case handler.error.level.INFO: |
log.info(error); |
break; |
case handler.error.level.WARN: |
log.warn(error); |
break; |
case handler.error.level.ERROR: |
log.error(error); |
break; |
} |
handler.process(config, request, response, root, (result) => { |
|
// Log the message by severity. |
log.log(result.severity, result.message); |
if(result.status) |
response.status = result.status; |
|
// If no data stream is made available or the content type is not |
// set then there is no further reason to bother with the request. |
if(typeof result.data === 'undefined' || result.data === null || |
typeof result.type === 'undefined' || result.type === null) |
return; |
|
// Set the content type and send the data. |
response.setHeader('Content-Type', result.type); |
result.data |
.on('open', () => result.data.pipe(response)); |
|
}) |
).listen(config.net.port, config.net.address, () => { |
log.info('HTTP Server accessible at: http://' + |
@@ -130,18 +138,22 @@ |
cert: certificates.certificate, |
}, |
(request, response) => |
handler.process(config, request, response, root, (error, level) => { |
switch (level) { |
case handler.error.level.INFO: |
log.info(error); |
break; |
case handler.error.level.WARN: |
log.warn(error); |
break; |
case handler.error.level.ERROR: |
log.error(error); |
break; |
} |
handler.process(config, request, response, root, (result) => { |
// Log the message by severity. |
log.log(result.severity, result.message); |
if(result.status) |
response.status = result.status; |
|
// If no data stream is made available or the content type is not |
// set then there is no further reason to bother with the request. |
if(typeof result.data === 'undefined' || result.data === null || |
typeof result.type === 'undefined' || result.type === null) |
return; |
|
// Set the content type and send the data. |
response.setHeader('Content-Type', result.type); |
result.data |
.on('open', () => result.data.pipe(response)); |
}) |
).listen(config.ssl.port, config.ssl.address, () => { |
log.info('HTTPs Server accessible at: https://' + |