package admin

import (
	"bufio"
	"gitote/gitote/pkg/context"
	"io/ioutil"
	"os"
)

const (
	LOGS = "admin/logs"
)

var Log struct {
	AppLog string
}

func Logs(c *context.Context) {
	c.Data["Title"] = "Application Logs"
	c.Data["PageIsAdminLogs"] = true

	f, _ := os.Open("log/gitote.log")

	reader := bufio.NewReader(f)
	content, _ := ioutil.ReadAll(reader)

	Log.AppLog = string(content)

	c.Data["AppLog"] = Log.AppLog
	c.HTML(200, LOGS)
}
