Merge branch 'main' into add-authentik-widget

This commit is contained in:
Jason Fischer 2022-09-23 20:02:12 -07:00
commit b0ab1d652a
No known key found for this signature in database
15 changed files with 241 additions and 153 deletions

View File

@ -94,6 +94,10 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
# https://github.com/docker/setup-qemu-action#about # https://github.com/docker/setup-qemu-action#about
# platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 # platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6

View File

@ -22,6 +22,10 @@ RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm i
FROM node:current-alpine AS builder FROM node:current-alpine AS builder
WORKDIR /app WORKDIR /app
ARG BUILDTIME
ARG VERSION
ARG REVISION
COPY --link --from=deps /app/node_modules ./node_modules/ COPY --link --from=deps /app/node_modules ./node_modules/
COPY . . COPY . .
@ -29,7 +33,7 @@ RUN <<EOF
set -xe set -xe
yarn next telemetry disable yarn next telemetry disable
mkdir config && echo '-' > config/settings.yaml mkdir config && echo '-' > config/settings.yaml
npm run build NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
EOF EOF
# Production image, copy all the files and run next # Production image, copy all the files and run next

View File

@ -13,6 +13,7 @@
"@headlessui/react": "^1.7.0", "@headlessui/react": "^1.7.0",
"@tailwindcss/forms": "^0.5.3", "@tailwindcss/forms": "^0.5.3",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"compare-versions": "^5.0.1",
"dockerode": "^3.3.4", "dockerode": "^3.3.4",
"follow-redirects": "^1.15.2", "follow-redirects": "^1.15.2",
"i18next": "^21.9.1", "i18next": "^21.9.1",

View File

@ -5,6 +5,7 @@ specifiers:
'@tailwindcss/forms': ^0.5.3 '@tailwindcss/forms': ^0.5.3
autoprefixer: ^10.4.9 autoprefixer: ^10.4.9
classnames: ^2.3.1 classnames: ^2.3.1
compare-versions: ^5.0.1
dockerode: ^3.3.4 dockerode: ^3.3.4
eslint: ^8.23.1 eslint: ^8.23.1
eslint-config-airbnb: ^19.0.4 eslint-config-airbnb: ^19.0.4
@ -45,6 +46,7 @@ dependencies:
'@headlessui/react': 1.7.0_biqbaboplfbrettd7655fr4n2y '@headlessui/react': 1.7.0_biqbaboplfbrettd7655fr4n2y
'@tailwindcss/forms': 0.5.3_tailwindcss@3.1.8 '@tailwindcss/forms': 0.5.3_tailwindcss@3.1.8
classnames: 2.3.1 classnames: 2.3.1
compare-versions: 5.0.1
dockerode: 3.3.4 dockerode: 3.3.4
follow-redirects: 1.15.2 follow-redirects: 1.15.2
i18next: 21.9.1 i18next: 21.9.1
@ -715,6 +717,10 @@ packages:
delayed-stream: 1.0.0 delayed-stream: 1.0.0
dev: false dev: false
/compare-versions/5.0.1:
resolution: {integrity: sha512-v8Au3l0b+Nwkp4G142JcgJFh1/TUhdxut7wzD1Nq1dyp5oa3tXaqb03EXOAB6jS4gMlalkjAUPZBMiAfKUixHQ==}
dev: false
/concat-map/0.0.1: /concat-map/0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true dev: true

View File

@ -159,14 +159,14 @@
"seed": "Seed" "seed": "Seed"
}, },
"mastodon": { "mastodon": {
"user_count": "Users", "user_count": "Nutzer",
"status_count": "Posts", "status_count": "Beiträge",
"domain_count": "Domains" "domain_count": "Domänen"
}, },
"strelaysrv": { "strelaysrv": {
"numActiveSessions": "Sessions", "numActiveSessions": "Sitzungen",
"numConnections": "Connections", "numConnections": "Verbindungen",
"dataRelayed": "Relayed", "dataRelayed": "Weitergeleitet",
"transferRate": "Rate" "transferRate": "Bewerten"
} }
} }

View File

@ -35,7 +35,7 @@
"rutorrent": { "rutorrent": {
"active": "Activo", "active": "Activo",
"upload": "Subida", "upload": "Subida",
"download": "Descarga" "download": "Bajada"
}, },
"sonarr": { "sonarr": {
"wanted": "Más deseado", "wanted": "Más deseado",
@ -69,7 +69,7 @@
}, },
"speedtest": { "speedtest": {
"upload": "Subida", "upload": "Subida",
"download": "Descarga", "download": "Bajada",
"ping": "Ping" "ping": "Ping"
}, },
"portainer": { "portainer": {
@ -88,7 +88,7 @@
"total": "Total" "total": "Total"
}, },
"weather": { "weather": {
"current": "Localización Actual", "current": "Ubicación actual",
"allow": "Clic para permitir", "allow": "Clic para permitir",
"updating": "Actualizando", "updating": "Actualizando",
"wait": "Espere, por favor" "wait": "Espere, por favor"
@ -128,7 +128,7 @@
"numberOfFailQueries": "Consultas fallidas" "numberOfFailQueries": "Consultas fallidas"
}, },
"transmission": { "transmission": {
"download": "Descarga", "download": "Bajada",
"upload": "Subida", "upload": "Subida",
"leech": "Compañeros", "leech": "Compañeros",
"seed": "Semillas" "seed": "Semillas"
@ -153,7 +153,7 @@
"latency": "Latencia" "latency": "Latencia"
}, },
"qbittorrent": { "qbittorrent": {
"download": "Descarga", "download": "Bajada",
"upload": "Subida", "upload": "Subida",
"leech": "Compañeros", "leech": "Compañeros",
"seed": "Semillas" "seed": "Semillas"
@ -166,7 +166,7 @@
"strelaysrv": { "strelaysrv": {
"numActiveSessions": "Sesiones", "numActiveSessions": "Sesiones",
"numConnections": "Conexiones", "numConnections": "Conexiones",
"dataRelayed": "Transmitido", "dataRelayed": "Retransmitido",
"transferRate": "Velocidad" "transferRate": "Velocidad"
} }
} }

View File

@ -38,18 +38,18 @@
"download": "Réception" "download": "Réception"
}, },
"sonarr": { "sonarr": {
"wanted": "Demandé", "wanted": "Demande",
"queued": "En queue", "queued": "En attente",
"series": "Séries" "series": "Séries"
}, },
"radarr": { "radarr": {
"wanted": "Demandé", "wanted": "Demande",
"queued": "En queue", "queued": "En attente",
"movies": "Films" "movies": "Films"
}, },
"readarr": { "readarr": {
"wanted": "Demandé", "wanted": "Demande",
"queued": "En Queue", "queued": "Attente",
"books": "Livres" "books": "Livres"
}, },
"ombi": { "ombi": {
@ -132,11 +132,11 @@
"messages": "Msg" "messages": "Msg"
}, },
"prowlarr": { "prowlarr": {
"enableIndexers": "Indexeurs", "enableIndexers": "Indexeur",
"numberOfGrabs": "Capture", "numberOfGrabs": "Capture",
"numberOfQueries": "Demandes", "numberOfQueries": "Demande",
"numberOfFailGrabs": "Capture échouée", "numberOfFailGrabs": "Capt. échouée",
"numberOfFailQueries": "Demande échouée" "numberOfFailQueries": "Dem. échouée"
}, },
"transmission": { "transmission": {
"download": "Réception", "download": "Réception",
@ -176,8 +176,8 @@
}, },
"strelaysrv": { "strelaysrv": {
"numActiveSessions": "Sessions", "numActiveSessions": "Sessions",
"numConnections": "Connections", "numConnections": "Cnx",
"dataRelayed": "Relayed", "dataRelayed": "Relayé",
"transferRate": "Rate" "transferRate": "Débit"
} }
} }

View File

@ -11,7 +11,7 @@
"total": "Total", "total": "Total",
"free": "Livre", "free": "Livre",
"used": "Usado", "used": "Usado",
"load": "Load" "load": "Carregar"
}, },
"docker": { "docker": {
"rx": "Rx", "rx": "Rx",
@ -23,7 +23,7 @@
"emby": { "emby": {
"playing": "A reproduzir", "playing": "A reproduzir",
"transcoding": "Transcodificação", "transcoding": "Transcodificação",
"bitrate": "Bitrate", "bitrate": "Taxa de bits",
"no_active": "Sem streams ativas" "no_active": "Sem streams ativas"
}, },
"tautulli": { "tautulli": {
@ -34,8 +34,8 @@
}, },
"rutorrent": { "rutorrent": {
"active": "Ativo", "active": "Ativo",
"upload": "Envio", "upload": "Enviando",
"download": "ReceçãoDownload" "download": "Baixando"
}, },
"sonarr": { "sonarr": {
"wanted": "Desejada", "wanted": "Desejada",
@ -48,7 +48,7 @@
"movies": "Filmes" "movies": "Filmes"
}, },
"readarr": { "readarr": {
"wanted": "Wanted", "wanted": "Desejados",
"queued": "Em fila", "queued": "Em fila",
"books": "Livros" "books": "Livros"
}, },
@ -65,7 +65,7 @@
"pihole": { "pihole": {
"queries": "Consultas", "queries": "Consultas",
"blocked": "Bloqueado", "blocked": "Bloqueado",
"gravity": "Gravity" "gravity": "Gravidade"
}, },
"speedtest": { "speedtest": {
"upload": "Envio", "upload": "Envio",
@ -78,7 +78,7 @@
"total": "Total" "total": "Total"
}, },
"traefik": { "traefik": {
"routers": "Routers", "routers": "Roteadores",
"services": "Serviços", "services": "Serviços",
"middleware": "Middleware" "middleware": "Middleware"
}, },
@ -110,21 +110,21 @@
"available": "Disponível" "available": "Disponível"
}, },
"sabnzbd": { "sabnzbd": {
"rate": "Rate", "rate": "Taxa",
"queue": "Fila", "queue": "Fila",
"timeleft": "Tempo restante" "timeleft": "Tempo restante"
}, },
"nzbget": { "nzbget": {
"rate": "Rate", "rate": "Taxa",
"remaining": "Restante", "remaining": "Restante",
"downloaded": "Downloaded" "downloaded": "Baixado"
}, },
"coinmarketcap": { "coinmarketcap": {
"configure": "Configurar uma ou mais moedas", "configure": "Configurar uma ou mais moedas",
"1hour": "1 Hour", "1hour": "1 Hora",
"1day": "1 Day", "1day": "1 Dia",
"7days": "7 Days", "7days": "7 Dias",
"30days": "30 Days" "30days": "30 Dias"
}, },
"gotify": { "gotify": {
"apps": "Aplicações", "apps": "Aplicações",
@ -132,52 +132,52 @@
"messages": "Mensagens" "messages": "Mensagens"
}, },
"prowlarr": { "prowlarr": {
"enableIndexers": "Indexers", "enableIndexers": "Indexadores",
"numberOfGrabs": "Grabs", "numberOfGrabs": "Agarrados",
"numberOfQueries": "Queries", "numberOfQueries": "Consultas",
"numberOfFailGrabs": "Falhados", "numberOfFailGrabs": "Falhados",
"numberOfFailQueries": "Pesquisas falhadas" "numberOfFailQueries": "Pesquisas falhadas"
}, },
"transmission": { "transmission": {
"download": "Download", "download": "Baixando",
"upload": "Envio", "upload": "Enviando",
"leech": "Leech", "leech": "Sanguessugas",
"seed": "Seed" "seed": "Semeadores"
}, },
"jackett": { "jackett": {
"configured": "Configured", "configured": "Configurado",
"errored": "Errored" "errored": "Errado"
}, },
"bazarr": { "bazarr": {
"missingEpisodes": "Missing Episodes", "missingEpisodes": "Episódios Faltantes",
"missingMovies": "Missing Movies" "missingMovies": "Filmes Faltantes"
}, },
"lidarr": { "lidarr": {
"queued": "Queued", "queued": "Enfileirado",
"wanted": "Wanted", "wanted": "Desejado",
"albums": "Albums" "albums": "Álbuns"
}, },
"adguard": { "adguard": {
"queries": "Queries", "queries": "Consultas",
"blocked": "Blocked", "blocked": "Bloqueado",
"filtered": "Filtered", "filtered": "Filtrado",
"latency": "Latency" "latency": "Latência"
}, },
"qbittorrent": { "qbittorrent": {
"download": "Download", "download": "Baixando",
"upload": "Upload", "upload": "Enviando",
"leech": "Leech", "leech": "Sanguessugas",
"seed": "Seed" "seed": "Semeadores"
}, },
"mastodon": { "mastodon": {
"user_count": "Users", "user_count": "Usuários",
"status_count": "Posts", "status_count": "Postagens",
"domain_count": "Domains" "domain_count": "Domínios"
}, },
"strelaysrv": { "strelaysrv": {
"numActiveSessions": "Sessions", "numActiveSessions": "Sessões",
"numConnections": "Connections", "numConnections": "Conexões",
"dataRelayed": "Relayed", "dataRelayed": "Retransmitido",
"transferRate": "Rate" "transferRate": "Taxa"
} }
} }

View File

@ -138,34 +138,34 @@
"prowlarr": { "prowlarr": {
"enableIndexers": "Indexerare", "enableIndexers": "Indexerare",
"numberOfGrabs": "Hämtningar", "numberOfGrabs": "Hämtningar",
"numberOfQueries": "Queries", "numberOfQueries": "Hämtningar",
"numberOfFailGrabs": "Misslyckade hämtningar", "numberOfFailGrabs": "Misslyckade hämtningar",
"numberOfFailQueries": "Fail Queries" "numberOfFailQueries": "Misslyckade hämtningar"
}, },
"jackett": { "jackett": {
"configured": "Konfigurerade", "configured": "Konfigurerade",
"errored": "Felaktiga" "errored": "Felaktiga"
}, },
"adguard": { "adguard": {
"queries": "Queries", "queries": "Förfrågningar",
"blocked": "Blocked", "blocked": "Blockerad",
"filtered": "Filtered", "filtered": "Filtrerad",
"latency": "Latency" "latency": "Svarstid"
}, },
"qbittorrent": { "qbittorrent": {
"download": "Download", "download": "Nedladdning",
"upload": "Upload", "upload": "Uppladdning",
"leech": "Leech", "leech": "Leech",
"seed": "Seed" "seed": "Seed"
}, },
"mastodon": { "mastodon": {
"user_count": "Users", "user_count": "Användare",
"status_count": "Posts", "status_count": "Posts",
"domain_count": "Domains" "domain_count": "Domains"
}, },
"strelaysrv": { "strelaysrv": {
"numActiveSessions": "Sessions", "numActiveSessions": "Sessioner",
"numConnections": "Connections", "numConnections": "Anslutningar",
"dataRelayed": "Relayed", "dataRelayed": "Relayed",
"transferRate": "Rate" "transferRate": "Rate"
} }

View File

@ -130,7 +130,7 @@
"transmission": { "transmission": {
"download": "下载", "download": "下载",
"upload": "上传", "upload": "上传",
"leech": "吸血", "leech": "下载中",
"seed": "做种" "seed": "做种"
}, },
"jackett": { "jackett": {
@ -155,11 +155,11 @@
"qbittorrent": { "qbittorrent": {
"download": "下载", "download": "下载",
"upload": "上传", "upload": "上传",
"leech": "吸血", "leech": "下载中",
"seed": "做种" "seed": "做种"
}, },
"mastodon": { "mastodon": {
"user_count": "Users", "user_count": "用户",
"status_count": "Posts", "status_count": "Posts",
"domain_count": "Domains" "domain_count": "Domains"
}, },

View File

@ -0,0 +1,47 @@
import { useTranslation } from "react-i18next";
import useSWR from "swr";
import { compareVersions } from "compare-versions";
import { MdNewReleases } from "react-icons/md";
export default function Version() {
const { t, i18n } = useTranslation();
const buildTime = process.env.NEXT_PUBLIC_BUILDTIME ?? new Date().toISOString();
const revision = process.env.NEXT_PUBLIC_REVISION ?? "dev";
const version = process.env.NEXT_PUBLIC_VERSION ?? "dev";
const { data: releaseData } = useSWR("https://api.github.com/repos/benphelps/homepage/releases");
// use Intl.DateTimeFormat to format the date
const formatDate = (date) => {
const options = {
year: "numeric",
month: "short",
day: "numeric",
};
return new Intl.DateTimeFormat(i18n.language, options).format(new Date(date));
};
const latestRelease = releaseData?.[0];
return (
<div className="flex flex-row items-center">
<span className="text-xs text-theme-500 opacity-50">
{version} ({revision.substring(0, 7)}, {formatDate(buildTime)})
</span>
{version === "main" || version === "dev"
? null
: releaseData &&
compareVersions(latestRelease.tag_name, version) > 0 && (
<a
href={latestRelease.html_url}
target="_blank"
rel="noopener noreferrer"
className="ml-2 text-xs text-theme-500 opacity-50 flex flex-row items-center"
>
<MdNewReleases className="mr-1" /> {t("Update Available")}
</a>
)}
</div>
);
}

View File

@ -1,4 +1,4 @@
import logger from "utils/logger"; import createLogger from "utils/logger";
import genericProxyHandler from "utils/proxies/generic"; import genericProxyHandler from "utils/proxies/generic";
import credentialedProxyHandler from "utils/proxies/credentialed"; import credentialedProxyHandler from "utils/proxies/credentialed";
import rutorrentProxyHandler from "utils/proxies/rutorrent"; import rutorrentProxyHandler from "utils/proxies/rutorrent";
@ -7,6 +7,8 @@ import npmProxyHandler from "utils/proxies/npm";
import transmissionProxyHandler from "utils/proxies/transmission"; import transmissionProxyHandler from "utils/proxies/transmission";
import qbittorrentProxyHandler from "utils/proxies/qbittorrent"; import qbittorrentProxyHandler from "utils/proxies/qbittorrent";
const logger = createLogger('servicesProxy');
function asJson(data) { function asJson(data) {
if (data?.length > 0) { if (data?.length > 0) {
const json = JSON.parse(data.toString()); const json = JSON.parse(data.toString());

View File

@ -10,6 +10,7 @@ import ServicesGroup from "components/services/group";
import BookmarksGroup from "components/bookmarks/group"; import BookmarksGroup from "components/bookmarks/group";
import Widget from "components/widget"; import Widget from "components/widget";
import Revalidate from "components/revalidate"; import Revalidate from "components/revalidate";
import createLogger from "utils/logger";
import { getSettings } from "utils/config"; import { getSettings } from "utils/config";
import { ColorContext } from "utils/color-context"; import { ColorContext } from "utils/color-context";
import { ThemeContext } from "utils/theme-context"; import { ThemeContext } from "utils/theme-context";
@ -23,10 +24,16 @@ const ColorToggle = dynamic(() => import("components/color-toggle"), {
ssr: false, ssr: false,
}); });
const Version = dynamic(() => import("components/version"), {
ssr: false,
});
const rightAlignedWidgets = ["weatherapi", "openweathermap", "weather", "search", "datetime"]; const rightAlignedWidgets = ["weatherapi", "openweathermap", "weather", "search", "datetime"];
export function getStaticProps() { export function getStaticProps() {
let logger;
try { try {
logger = createLogger("index");
const { providers, ...settings } = getSettings(); const { providers, ...settings } = getSettings();
return { return {
@ -35,6 +42,9 @@ export function getStaticProps() {
}, },
}; };
} catch (e) { } catch (e) {
if (logger) {
logger.error(e);
}
return { return {
props: { props: {
initialSettings: {}, initialSettings: {},
@ -153,11 +163,15 @@ function Home({ initialSettings }) {
</div> </div>
)} )}
<div className="rounded-full flex p-8 w-full justify-end"> <div className="flex p-8 pb-0 w-full justify-end">
{!settings?.color && <ColorToggle />} {!settings?.color && <ColorToggle />}
<Revalidate /> <Revalidate />
{!settings?.theme && <ThemeToggle />} {!settings?.theme && <ThemeToggle />}
</div> </div>
<div className="flex p-8 pt-4 w-full justify-end">
<Version />
</div>
</div> </div>
</> </>
); );

View File

@ -1,80 +1,88 @@
/* eslint-disable no-console */
import { join } from "path"; import { join } from "path";
import { format as utilFormat } from "node:util"
import winston from "winston"; import winston from "winston";
const configPath = join(process.cwd(), "config"); let winstonLogger;
function messageFormatter(logInfo) { function init() {
if (logInfo.stack) { const configPath = join(process.cwd(), "config");
return `[${logInfo.timestamp}] ${logInfo.level}: ${logInfo.stack}`;
function combineMessageAndSplat() {
return {
// eslint-disable-next-line no-unused-vars
transform: (info, opts) => {
// combine message and args if any
// eslint-disable-next-line no-param-reassign
info.message = utilFormat(info.message, ...info[Symbol.for('splat')] || []);
return info;
}
}
} }
return `[${logInfo.timestamp}] ${logInfo.level}: ${logInfo.message}`;
};
const consoleFormat = winston.format.combine( function messageFormatter(logInfo) {
winston.format.errors({ stack: true }), if (logInfo.label) {
winston.format.splat(), if (logInfo.stack) {
winston.format.timestamp(), return `[${logInfo.timestamp}] ${logInfo.level}: <${logInfo.label}> ${logInfo.stack}`;
winston.format.colorize(), }
winston.format.printf(messageFormatter) return `[${logInfo.timestamp}] ${logInfo.level}: <${logInfo.label}> ${logInfo.message}`;
); }
const fileFormat = winston.format.combine( if (logInfo.stack) {
winston.format.errors({ stack: true }), return `[${logInfo.timestamp}] ${logInfo.level}: ${logInfo.stack}`;
winston.format.splat(), }
winston.format.timestamp(), return `[${logInfo.timestamp}] ${logInfo.level}: ${logInfo.message}`;
winston.format.printf(messageFormatter) };
);
const logger = winston.createLogger({ winstonLogger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info', level: process.env.LOG_LEVEL || 'info',
transports: [ transports: [
new winston.transports.Console({ new winston.transports.Console({
format: consoleFormat, format: winston.format.combine(
handleExceptions: true, winston.format.errors({ stack: true}),
handleRejections: true combineMessageAndSplat(),
}), winston.format.timestamp(),
winston.format.colorize(),
winston.format.printf(messageFormatter)
),
handleExceptions: true,
handleRejections: true
}),
new winston.transports.File({ new winston.transports.File({
format: fileFormat, format: winston.format.combine(
filename: `${configPath}/logs/homepage.log`, winston.format.errors({ stack: true}),
handleExceptions: true, combineMessageAndSplat(),
handleRejections: true winston.format.timestamp(),
}), winston.format.printf(messageFormatter)
] ),
}); filename: `${configPath}/logs/homepage.log`,
handleExceptions: true,
handleRejections: true
}),
]
});
function debug(message, ...args) { // patch the console log mechanism to use our logger
logger.debug(message, ...args); const consoleMethods = ['log', 'debug', 'info', 'warn', 'error']
consoleMethods.forEach(method => {
// workaround for https://github.com/winstonjs/winston/issues/1591
switch (method) {
case 'log':
console[method] = winstonLogger.info.bind(winstonLogger);
break;
default:
console[method] = winstonLogger[method].bind(winstonLogger);
break;
}
})
} }
function verbose(message, ...args) { export default function createLogger(label) {
logger.verbose(message, ...args); if (!winstonLogger) {
} init();
}
function info(message, ...args) { return winstonLogger.child({ label });
logger.info(message, ...args); }
}
function warn(message, ...args) {
logger.warn(message, ...args);
}
function error(message, ...args) {
logger.error(message, ...args);
}
function crit(message, ...args) {
logger.crit(message, ...args);
}
const thisModule = {
debug,
verbose,
info,
warn,
error,
crit
};
export default thisModule;

View File

@ -1,7 +1,9 @@
import getServiceWidget from "utils/service-helpers"; import getServiceWidget from "utils/service-helpers";
import { formatApiCall } from "utils/api-helpers"; import { formatApiCall } from "utils/api-helpers";
import { httpProxy } from "utils/http"; import { httpProxy } from "utils/http";
import logger from "utils/logger"; import createLogger from "utils/logger";
const logger = createLogger('genericProxyHandler');
export default async function genericProxyHandler(req, res, maps) { export default async function genericProxyHandler(req, res, maps) {
const { group, service, endpoint } = req.query; const { group, service, endpoint } = req.query;