Skip to content

Commit

Permalink
Feat: change logger verbosity and spelling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Its4Nik committed Jan 17, 2025
1 parent 65bcec8 commit 92bfd8b
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 96 deletions.
151 changes: 71 additions & 80 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,109 +4,100 @@ This file shows all npm packages used in DockStatAPI (also Dev packages)

### License: (MIT AND CC-BY-3.0)

| Name | Repository | Publisher |
|------|-------------|-----------|
| Name | Repository | Publisher |
| ----------------- | -------------------------------------------- | -------------------- |
| [email protected] | https://github.com/kemitchell/spdx-ranges.js | The Linux Foundation |


### License: Apache 2.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| [email protected] | https://github.com/gtanner/qrcode-terminal | N/A |

| Name | Repository | Publisher |
| ---------------------- | ------------------------------------------ | --------- |
| [email protected] | https://github.com/gtanner/qrcode-terminal | N/A |

### License: Apache-2.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| @ampproject/remapping@2.3.0 | https://github.com/ampproject/remapping | Justin Ridgewell |
| @balena/dockerignore@1.0.2 | https://github.com/balena-io-modules/dockerignore | N/A |
| @eslint/config-array@0.19.1 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @eslint/core@0.9.1 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @eslint/object-schema@2.1.5 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @eslint/plugin-kit@0.2.4 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @humanfs/core@0.19.1 | https://github.com/humanwhocodes/humanfs | Nicholas C. Zakas |
| @humanfs/node@0.16.6 | https://github.com/humanwhocodes/humanfs | Nicholas C. Zakas |
| @humanwhocodes/module-importer@1.0.1 | https://github.com/humanwhocodes/module-importer | Nicholas C. Zaks |
| @humanwhocodes/retry@0.3.1 | https://github.com/humanwhocodes/retry | Nicholas C. Zaks |
| @humanwhocodes/retry@0.4.1 | https://github.com/humanwhocodes/retry | Nicholas C. Zaks |
| @puppeteer/browsers@2.7.0 | https://github.com/puppeteer/puppeteer/tree/main/packages/browsers | The Chromium Authors |
| @scarf/scarf@1.4.0 | https://github.com/scarf-sh/scarf-js | Scarf Systems |
| @sigstore/bundle@3.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/core@2.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/protobuf-specs@0.3.2 | https://github.com/sigstore/protobuf-specs | [email protected] |
| @sigstore/sign@3.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/tuf@3.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/verify@2.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| [email protected] | https://github.com/holepunchto/b4a | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-events | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-fs | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-os | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-path | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-stream | Holepunch |
| [email protected] | https://github.com/facebook/watchman | Wez Furlong |
| [email protected] | https://github.com/GoogleChromeLabs/chromium-bidi | The Chromium Authors |
| [email protected] | https://github.com/GoogleChromeLabs/chromium-bidi | The Chromium Authors |
| [email protected] | https://github.com/lovell/detect-libc | Lovell Fuller |
| [email protected] | https://github.com/apocas/docker-modem | Pedro Dias |
| [email protected] | https://github.com/apocas/dockerode | Pedro Dias |
| [email protected] | https://github.com/mde/ejs | Matthew Eernisse |
| [email protected] | https://github.com/eslint/eslint-visitor-keys | Toru Nagashima |
| [email protected] | https://github.com/eslint/js | Toru Nagashima |
| [email protected] | https://github.com/coveo/exponential-backoff | Sami Sayegh |
| [email protected] | https://github.com/facebook/watchman | Wez Furlong |
| [email protected] | https://github.com/mde/filelist | Matthew Eernisse |
| [email protected] | https://github.com/ehmicky/human-signals | ehmicky |
| [email protected] | https://github.com/jakejs/jake | Matthew Eernisse |
| [email protected] | https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer-core | The Chromium Authors |
| [email protected] | https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer | The Chromium Authors |
| [email protected] | https://github.com/sigstore/sigstore-js | [email protected] |
| [email protected] | https://github.com/jslicense/spdx-correct.js | N/A |
| [email protected] | https://github.com/swagger-api/swagger-ui | N/A |
| [email protected] | https://github.com/holepunchto/text-decoder | Holepunch |
| [email protected] | https://github.com/mikeal/tunnel-agent | Mikeal Rogers |
| [email protected] | https://github.com/microsoft/TypeScript | Microsoft Corp. |
| [email protected] | https://github.com/kemitchell/validate-npm-package-license.js | Kyle E. Mitchell |
| [email protected] | https://github.com/daaku/nodejs-walker | Naitik Shah |

| Name | Repository | Publisher |
| ------------------------------------ | ------------------------------------------------------------------------ | -------------------- |
| @ampproject/remapping@2.3.0 | https://github.com/ampproject/remapping | Justin Ridgewell |
| @balena/dockerignore@1.0.2 | https://github.com/balena-io-modules/dockerignore | N/A |
| @eslint/config-array@0.19.1 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @eslint/core@0.9.1 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @eslint/object-schema@2.1.5 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @eslint/plugin-kit@0.2.4 | https://github.com/eslint/rewrite | Nicholas C. Zakas |
| @humanfs/core@0.19.1 | https://github.com/humanwhocodes/humanfs | Nicholas C. Zakas |
| @humanfs/node@0.16.6 | https://github.com/humanwhocodes/humanfs | Nicholas C. Zakas |
| @humanwhocodes/module-importer@1.0.1 | https://github.com/humanwhocodes/module-importer | Nicholas C. Zaks |
| @humanwhocodes/retry@0.3.1 | https://github.com/humanwhocodes/retry | Nicholas C. Zaks |
| @humanwhocodes/retry@0.4.1 | https://github.com/humanwhocodes/retry | Nicholas C. Zaks |
| @puppeteer/browsers@2.7.0 | https://github.com/puppeteer/puppeteer/tree/main/packages/browsers | The Chromium Authors |
| @scarf/scarf@1.4.0 | https://github.com/scarf-sh/scarf-js | Scarf Systems |
| @sigstore/bundle@3.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/core@2.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/protobuf-specs@0.3.2 | https://github.com/sigstore/protobuf-specs | [email protected] |
| @sigstore/sign@3.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/tuf@3.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| @sigstore/verify@2.0.0 | https://github.com/sigstore/sigstore-js | [email protected] |
| [email protected] | https://github.com/holepunchto/b4a | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-events | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-fs | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-os | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-path | Holepunch |
| [email protected] | https://github.com/holepunchto/bare-stream | Holepunch |
| [email protected] | https://github.com/facebook/watchman | Wez Furlong |
| [email protected] | https://github.com/GoogleChromeLabs/chromium-bidi | The Chromium Authors |
| [email protected] | https://github.com/GoogleChromeLabs/chromium-bidi | The Chromium Authors |
| [email protected] | https://github.com/lovell/detect-libc | Lovell Fuller |
| [email protected] | https://github.com/apocas/docker-modem | Pedro Dias |
| [email protected] | https://github.com/apocas/dockerode | Pedro Dias |
| [email protected] | https://github.com/mde/ejs | Matthew Eernisse |
| [email protected] | https://github.com/eslint/eslint-visitor-keys | Toru Nagashima |
| [email protected] | https://github.com/eslint/js | Toru Nagashima |
| [email protected] | https://github.com/coveo/exponential-backoff | Sami Sayegh |
| [email protected] | https://github.com/facebook/watchman | Wez Furlong |
| [email protected] | https://github.com/mde/filelist | Matthew Eernisse |
| [email protected] | https://github.com/ehmicky/human-signals | ehmicky |
| [email protected] | https://github.com/jakejs/jake | Matthew Eernisse |
| [email protected] | https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer-core | The Chromium Authors |
| [email protected] | https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer | The Chromium Authors |
| [email protected] | https://github.com/sigstore/sigstore-js | [email protected] |
| [email protected] | https://github.com/jslicense/spdx-correct.js | N/A |
| [email protected] | https://github.com/swagger-api/swagger-ui | N/A |
| [email protected] | https://github.com/holepunchto/text-decoder | Holepunch |
| [email protected] | https://github.com/mikeal/tunnel-agent | Mikeal Rogers |
| [email protected] | https://github.com/microsoft/TypeScript | Microsoft Corp. |
| [email protected] | https://github.com/kemitchell/validate-npm-package-license.js | Kyle E. Mitchell |
| [email protected] | https://github.com/daaku/nodejs-walker | Naitik Shah |

### License: Artistic-2.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| Name | Repository | Publisher |
| ---------- | -------------------------- | ----------- |
| [email protected] | https://github.com/npm/cli | GitHub Inc. |


### License: BlueOak-1.0.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| [email protected] | https://github.com/isaacs/chownr | Isaac Z. Schlueter |
| [email protected] | https://github.com/isaacs/jackspeak | Isaac Z. Schlueter |
| Name | Repository | Publisher |
| ---------------------------- | ------------------------------------------------ | ------------------ |
| [email protected] | https://github.com/isaacs/chownr | Isaac Z. Schlueter |
| [email protected] | https://github.com/isaacs/jackspeak | Isaac Z. Schlueter |
| [email protected] | https://github.com/isaacs/package-json-from-dist | Isaac Z. Schlueter |
| [email protected] | https://github.com/isaacs/path-scurry | Isaac Z. Schlueter |
| [email protected] | https://github.com/isaacs/yallist | Isaac Z. Schlueter |

| [email protected] | https://github.com/isaacs/path-scurry | Isaac Z. Schlueter |
| [email protected] | https://github.com/isaacs/yallist | Isaac Z. Schlueter |

### License: CC-BY-3.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| Name | Repository | Publisher |
| --------------------- | -------------------------------------------------- | -------------------- |
| [email protected] | https://github.com/kemitchell/spdx-exceptions.json | The Linux Foundation |


### License: CC-BY-4.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| Name | Repository | Publisher |
| ------------------------- | -------------------------------------------- | ---------- |
| [email protected] | https://github.com/browserslist/caniuse-lite | Ben Briggs |


### License: Python-2.0

| Name | Repository | Publisher |
|------|-------------|-----------|
| [email protected] | https://github.com/nodeca/argparse | N/A |


| Name | Repository | Publisher |
| -------------- | ---------------------------------- | --------- |
| [email protected] | https://github.com/nodeca/argparse | N/A |
14 changes: 12 additions & 2 deletions src/config/hostsystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
VERSION,
HA_MASTER,
HA_UNSAFE,
TRUSTED_PROXYS,
TRUSTED_PROXIES,
LOG_LEVEL,
} from "./variables";
import fs from "fs";
import logger from "../utils/logger";
Expand All @@ -16,6 +17,14 @@ const version: string = VERSION || "unknown";
const masterNode: string = HA_MASTER === "true" ? "✓" : "✗";
const unsafeSync: string = HA_UNSAFE === "true" ? "✓" : "✗";

let trustedProxies: string = "";

if (TRUSTED_PROXIES) {
trustedProxies = TRUSTED_PROXIES;
} else {
trustedProxies = "✗";
}

function writeUserConf(port: number) {
let previousConfig = null;
let shouldRewriteConfig = false;
Expand Down Expand Up @@ -72,7 +81,8 @@ function writeUserConf(port: number) {
logger.info(`Arch : ${installationDetails.arch}`);
logger.info(`Master node : ${masterNode}`);
logger.info(`Unsafe sync : ${unsafeSync}`);
logger.info(`Proxies : ${TRUSTED_PROXYS}`);
logger.info(`Proxies : ${trustedProxies}`);
logger.info(`Log Level : ${LOG_LEVEL}`);
logger.info(`Server : http://localhost:${port}`);
if (process.env.NODE_ENV !== "production") {
logger.info(`Swagger-UI : http://localhost:${port}/api-docs`);
Expand Down
3 changes: 2 additions & 1 deletion src/config/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import vars from "../data/variables.json";
export const {
VERSION,
RUNNING_IN_DOCKER,
TRUSTED_PROXYS,
TRUSTED_PROXIES,
HA_MASTER,
HA_MASTER_IP,
HA_NODE,
Expand All @@ -22,4 +22,5 @@ export const {
WHATSAPP_API_URL,
WHATSAPP_RECIPIENT,
AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT,
LOG_LEVEL,
} = vars;
4 changes: 2 additions & 2 deletions src/controllers/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Application } from "express";
import logger from "../utils/logger";
import { TRUSTED_PROXYS } from "../config/variables";
import { TRUSTED_PROXIES } from "../config/variables";

export default function trustedProxies(app: Application) {
const trusted: string = TRUSTED_PROXYS;
const trusted: string = TRUSTED_PROXIES;

if (!trusted) {
logger.warn(
Expand Down
8 changes: 6 additions & 2 deletions src/misc/createEnvDev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ else
RUNNING_IN_DOCKER="false"
fi

# Default dev log level
LOG_LEVEL="${LOG_LEVEL:-debug}"

echo -n "\
{
\"VERSION\": \"${VERSION}\",
\"RUNNING_IN_DOCKER\": \"${RUNNING_IN_DOCKER}\",
\"TRUSTED_PROXYS\": \"${TRUSTED_PROXYS}\",
\"TRUSTED_PROXIES\": \"${TRUSTED_PROXIES}\",
\"HA_MASTER\": \"${HA_MASTER}\",
\"HA_MASTER_IP\": \"${HA_MASTER_IP}\",
\"HA_NODE\": \"${HA_NODE}\",
Expand All @@ -35,6 +38,7 @@ echo -n "\
\"TELEGRAM_CHAT_ID\": \"${TELEGRAM_CHAT_ID}\",
\"WHATSAPP_API_URL\": \"${WHATSAPP_API_URL}\",
\"WHATSAPP_RECIPIENT\": \"${WHATSAPP_RECIPIENT}\",
\"AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT\": \"${AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT}\"
\"AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT\": \"${AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT}\",
\"LOG_LEVEL\": \"${LOG_LEVEL}\"
} \
" > ./src/data/variables.json || exit 1
8 changes: 6 additions & 2 deletions src/misc/createEnvFile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ else
RUNNING_IN_DOCKER="false"
fi

# Default log level
LOG_LEVEL="${LOG_LEVEL:-info}"

echo -n "\
{
\"VERSION\": \"${VERSION}\",
\"RUNNING_IN_DOCKER\": \"${RUNNING_IN_DOCKER}\",
\"TRUSTED_PROXYS\": \"${TRUSTED_PROXYS}\",
\"TRUSTED_PROXIES\": \"${TRUSTED_PROXIES}\",
\"HA_MASTER\": \"${HA_MASTER}\",
\"HA_MASTER_IP\": \"${HA_MASTER_IP}\",
\"HA_NODE\": \"${HA_NODE}\",
Expand All @@ -35,6 +38,7 @@ echo -n "\
\"TELEGRAM_CHAT_ID\": \"${TELEGRAM_CHAT_ID}\",
\"WHATSAPP_API_URL\": \"${WHATSAPP_API_URL}\",
\"WHATSAPP_RECIPIENT\": \"${WHATSAPP_RECIPIENT}\",
\"AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT\": \"${AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT}\"
\"AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT\": \"${AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT}\",
\"LOG_LEVEL\": \"${LOG_LEVEL}\"
} \
" > /api/src/data/variables.json || exit 1
5 changes: 3 additions & 2 deletions src/sample-variable.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"VERSION": "",
"RUNNING_IN_DOCKER": "",
"TRUSTED_PROXYS": "",
"TRUSTED_PROXIES": "",
"HA_MASTER": "",
"HA_MASTER_IP": "",
"HA_NODE": "",
Expand All @@ -19,5 +19,6 @@
"TELEGRAM_CHAT_ID": "",
"WHATSAPP_API_URL": "",
"WHATSAPP_RECIPIENT": "",
"AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT": "true"
"AUTOMATIC_ENVIRONMENT_FILE_MANAGEMENT": "true",
"LOG_LEVEL": "info"
}
8 changes: 3 additions & 5 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createLogger, format, transports } from "winston";
import DailyRotateFile from "winston-daily-rotate-file";
import { LOG_LEVEL } from "../config/variables";

// ANSI color codes for log level customization
const colors = {
gray: "\x1b[90m",
reset: "\x1b[0m",
Expand All @@ -12,7 +12,6 @@ const colors = {
blue: "\x1b[34m",
};

// Custom formatter to colorize log levels
function colorizeLogLevel(level: string, levelName: string) {
switch (level) {
case "info":
Expand All @@ -28,7 +27,7 @@ function colorizeLogLevel(level: string, levelName: string) {
}
}

// Filter out unwanted logs (example: Exit listeners logs)
// Filter out Exit listeners logs
const filterLogs = format((info) => {
if (
typeof info.message === "string" &&
Expand All @@ -39,9 +38,8 @@ const filterLogs = format((info) => {
return info;
});

// Logger instance
const logger = createLogger({
level: "debug",
level: LOG_LEVEL,
format: format.combine(
filterLogs(),
format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
Expand Down

0 comments on commit 92bfd8b

Please sign in to comment.