mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-02 08:46:38 +00:00
Patch logger for ISO8601 TZ offsets and fix Docker build
- server/logger.ts: timestamps now use local TZ offset instead of Z - Dockerfile: replaced 'npm ci --omit=dev' with 'npm install --omit=dev' to fix Alpine build failure - References discussion: https://github.com/orgs/fosrl/discussions/1025 - Note: timestamps default to +00:00 (UTC) unless the user sets environment: TZ=<timezone> in docker-compose.yaml Optional future improvement: include tzdata in the container for shell/date consistency.
This commit is contained in:
@@ -29,7 +29,8 @@ RUN apk add --no-cache curl
|
|||||||
|
|
||||||
# COPY package.json package-lock.json ./
|
# COPY package.json package-lock.json ./
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci --omit=dev && npm cache clean --force
|
#RUN npm ci --omit=dev && npm cache clean --force
|
||||||
|
RUN npm install --omit=dev && npm cache clean --force
|
||||||
|
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
|||||||
@@ -5,6 +5,19 @@ import path from "path";
|
|||||||
import { APP_PATH } from "./lib/consts";
|
import { APP_PATH } from "./lib/consts";
|
||||||
import telemetryClient from "./lib/telemetry";
|
import telemetryClient from "./lib/telemetry";
|
||||||
|
|
||||||
|
// helper to get ISO8601 string in the TZ from process.env.TZ
|
||||||
|
const isoLocal = () => {
|
||||||
|
const tz = process.env.TZ || "UTC";
|
||||||
|
const d = new Date();
|
||||||
|
const s = d.toLocaleString("sv-SE", { timeZone: tz, hour12: false });
|
||||||
|
const tzOffsetMin = d.getTimezoneOffset();
|
||||||
|
const sign = tzOffsetMin <= 0 ? "+" : "-";
|
||||||
|
const pad = (n: number) => String(n).padStart(2, "0");
|
||||||
|
const hours = pad(Math.floor(Math.abs(tzOffsetMin) / 60));
|
||||||
|
const mins = pad(Math.abs(tzOffsetMin) % 60);
|
||||||
|
return s.replace(" ", "T") + `${sign}${hours}:${mins}`;
|
||||||
|
};
|
||||||
|
|
||||||
const hformat = winston.format.printf(
|
const hformat = winston.format.printf(
|
||||||
({ level, label, message, timestamp, stack, ...metadata }) => {
|
({ level, label, message, timestamp, stack, ...metadata }) => {
|
||||||
let msg = `${timestamp} [${level}]${label ? `[${label}]` : ""}: ${message}`;
|
let msg = `${timestamp} [${level}]${label ? `[${label}]` : ""}: ${message}`;
|
||||||
@@ -29,7 +42,12 @@ if (config.getRawConfig().app.save_logs) {
|
|||||||
maxSize: "20m",
|
maxSize: "20m",
|
||||||
maxFiles: "7d",
|
maxFiles: "7d",
|
||||||
createSymlink: true,
|
createSymlink: true,
|
||||||
symlinkName: "pangolin.log"
|
symlinkName: "pangolin.log",
|
||||||
|
format: winston.format.combine(
|
||||||
|
winston.format.timestamp({ format: isoLocal }),
|
||||||
|
winston.format.splat(),
|
||||||
|
hformat
|
||||||
|
)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
transports.push(
|
transports.push(
|
||||||
@@ -42,7 +60,7 @@ if (config.getRawConfig().app.save_logs) {
|
|||||||
createSymlink: true,
|
createSymlink: true,
|
||||||
symlinkName: ".machinelogs.json",
|
symlinkName: ".machinelogs.json",
|
||||||
format: winston.format.combine(
|
format: winston.format.combine(
|
||||||
winston.format.timestamp(),
|
winston.format.timestamp({ format: isoLocal }),
|
||||||
winston.format.splat(),
|
winston.format.splat(),
|
||||||
winston.format.json()
|
winston.format.json()
|
||||||
)
|
)
|
||||||
@@ -56,7 +74,7 @@ const logger = winston.createLogger({
|
|||||||
winston.format.errors({ stack: true }),
|
winston.format.errors({ stack: true }),
|
||||||
winston.format.colorize(),
|
winston.format.colorize(),
|
||||||
winston.format.splat(),
|
winston.format.splat(),
|
||||||
winston.format.timestamp(),
|
winston.format.timestamp({ format: isoLocal }),
|
||||||
hformat
|
hformat
|
||||||
),
|
),
|
||||||
transports
|
transports
|
||||||
|
|||||||
Reference in New Issue
Block a user