mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 06:38:46 +00:00
Added configurable setting for log folder, falls back to config path if not set
This commit is contained in:
parent
e24b534843
commit
83a3a06386
1 changed files with 5 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { format as utilFormat } from "node:util";
|
import { format as utilFormat } from "node:util";
|
||||||
|
import checkAndCopyConfig, { getSettings } from "utils/config/config";
|
||||||
|
|
||||||
import winston from "winston";
|
import winston from "winston";
|
||||||
|
|
||||||
|
@ -8,6 +9,9 @@ let winstonLogger;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
const configPath = join(process.cwd(), "config");
|
const configPath = join(process.cwd(), "config");
|
||||||
|
checkAndCopyConfig("settings.yaml");
|
||||||
|
const settings = getSettings();
|
||||||
|
const logpath = settings.logpath || configPath;
|
||||||
|
|
||||||
function combineMessageAndSplat() {
|
function combineMessageAndSplat() {
|
||||||
return {
|
return {
|
||||||
|
@ -57,7 +61,7 @@ function init() {
|
||||||
winston.format.timestamp(),
|
winston.format.timestamp(),
|
||||||
winston.format.printf(messageFormatter)
|
winston.format.printf(messageFormatter)
|
||||||
),
|
),
|
||||||
filename: `${configPath}/logs/homepage.log`,
|
filename: `${logpath}/logs/homepage.log`,
|
||||||
handleExceptions: true,
|
handleExceptions: true,
|
||||||
handleRejections: true,
|
handleRejections: true,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue