Better logging system

This commit is contained in:
Dessa Simpson 2020-09-19 11:23:44 -07:00
parent e5f96b966a
commit e9696fac25
3 changed files with 42 additions and 7 deletions

View file

@ -2,6 +2,7 @@ import * as config from "./config";
import * as requests from "./requests";
import * as twitch from "./twitch";
import * as queries from "./queries";
import { log, LogLevel } from "./logging"
import { URLSearchParams } from "url";
import express from "express";
import session from "express-session";
@ -11,6 +12,9 @@ import fetch, { Response as FetchResponse } from "node-fetch";
import db from "./db";
import errorHandler from "./errors";
console.log("Starting at " + new Date().toISOString());
// Ensure that any API token we have is valid - if not, destroy the session,
// logging out the user. Should be called before checking whether a user is
// logged in.
@ -300,7 +304,7 @@ app.get("/", async (request, response) => {
app.get("/logout", async (request, response) => request.session!.destroy(() => response.redirect(307, '/')));
async function processBannedUsers() {
console.log("processBannedUsers run at " + new Date().toISOString());
log(LogLevel.INFO,"processBannedUsers run at " + new Date().toISOString());
var streamer = await db.query(queries.getStreamerIdToken).then((result: pg.QueryResult) => result.rows[0]);
if (streamer['tokenpair'] != null) {
var response = await twitch.apiRequest(streamer['tokenpair'],"/moderation/banned?broadcaster_id=" + streamer['userid']);