basic logger functionality added - accessible via http://nodebb/admin/logger

v1.18.x
Andrew Darqui 11 years ago
parent aacd42f4bc
commit 55d84d0f9b

@ -84,6 +84,7 @@
<li class=''><a href='{relative_path}/admin/plugins'><i class='icon-code-fork'></i> Plugins</a></li>
<li class=''><a href='{relative_path}/admin/settings'><i class='icon-cogs'></i> Settings</a></li>
<li class=''><a href='{relative_path}/admin/redis'><i class='icon-hdd'></i> Redis</a></li>
<li class=''><a href='{relative_path}/admin/logger'><i class='icon-th'></i> Logger</a></li>
<li class=''><a href="{relative_path}/admin/motd"><i class="icon-comment"></i> MOTD</a></li>
<li class="nav-header">Social Authentication</li>

@ -0,0 +1,33 @@
<h1>Logger</h1>
<hr />
<h3>Logger Settings</h3>
<div class="alert alert-warning">
<p>
By enabling the check box, you will receive http logs to standard output. If you specify a path, logs will then be saved to a file instead.
</p>
<br/>
<form>
<label>
<input type="checkbox" data-field="loggerStatus"> <strong>Enable logging</strong>
</label>
<br/>
<label>Path to log file</label>
<input class="form-control" type="text" placeholder="/path/to/log/file.log" data-field="loggerPath" /><br />
</form>
</div>
<button class="btn btn-lg btn-primary" id="save">Save</button>
<script>
var loadDelay = setInterval(function() {
if (nodebb_admin) {
nodebb_admin.prepare();
clearInterval(loadDelay);
}
}, 500);
</script>

@ -11,6 +11,7 @@
"^admin/settings.*": "admin/settings",
"admin/twitter.*": "admin/twitter",
"admin/facebook.*": "admin/facebook",
"admin/logger.*": "admin/logger",
"admin/gplus.*": "admin/gplus",
"admin/motd/?$": "admin/motd",
"admin/groups/?$": "admin/groups",

@ -30,7 +30,7 @@ var user = require('./../user.js'),
(function () {
var routes = [
'categories/active', 'categories/disabled', 'users', 'topics', 'settings', 'themes',
'twitter', 'facebook', 'gplus', 'redis', 'motd', 'groups',
'twitter', 'facebook', 'gplus', 'redis', 'motd', 'groups','logger',
'users/latest', 'users/sort-posts', 'users/sort-reputation',
'users/search', 'plugins'
];
@ -224,6 +224,10 @@ var user = require('./../user.js'),
res.json(200, {});
});
app.get('/logger', function(req, res) {
res.json(200, {});
});
app.get('/themes', function (req, res) {
res.json(200, {});
});

@ -79,9 +79,16 @@ var express = require('express'),
function(next) {
// Pre-router middlewares
app.use(express.compress());
if(nconf.get("express:logger") == true) {
app.use(express.logger());
if(nconf.get("express:logger") == true || meta.config.loggerStatus > 0) {
var loggerObj = {};
if(meta.config.loggerPath) {
loggerObj.stream = fs.createWriteStream(meta.config.loggerPath, {flags: 'a'});
meta.config.loggerStream = loggerObj.stream
}
app.use(express.logger(loggerObj));
}
app.use(express.favicon(path.join(__dirname, '../', 'public', 'favicon.ico')));
app.use(require('less-middleware')({
src: path.join(__dirname, '../', 'public'),

Loading…
Cancel
Save