add express logging

This commit is contained in:
lucaspalomodevelop 2022-03-10 20:10:27 +01:00
parent 9af4b6e223
commit 8ecf2f40b7
5 changed files with 53 additions and 49 deletions

View File

@ -19,10 +19,10 @@ console.log = function (d) {
log_file.write(d);
log_stdout.write(d);
};
console.error = console.log;
function getCurrentlog() {
return fs.readFileSync(__dirname + "/../../logs/" + name, "utf8").toString();
// .replace(/\n/g, "<br>");
}
module.exports = { getCurrentlog };

View File

@ -15,7 +15,7 @@ websrv.slisten((host, port) => {
* Stops the server
*/
process.on("SIGINT", () => {
console.log("\nWeb-Server Beenden ...");
console.log("Web-Server Beenden ...");
websrv.close();
process.exit();
});

View File

@ -10,11 +10,17 @@ module.exports = function (conf) {
const internalRouter = require("./routes/internalRouter");
app.use((req, res, next) => {
res.on("finish", () => {
console.log(`${req.method} ${req.url} ${res.statusCode}`);
});
next();
});
app.use(cors());
app.use(bodyParser.json());
app.use(cookieParser());
app.use("/api", internalRouter);
app.use("/dashboard", express.static(__dirname + "/../../dashboard"));
app.slisten = function (cb) {
app.ServerInstance = app

View File

@ -5,7 +5,6 @@ const States = require("../../helper/states");
const logger = require("../../helper/logger");
router.get("/conf", (req, res) => {
console.log(conf);
res.json(conf);
});

View File

@ -57,7 +57,6 @@ function test() {
</body>
</html>`
);
console.log(result);
});
it("should not rendern _VAR_", function () {