chore: Decouple verbose logging from staging (#160)

* Decoupled verbose logs from staging mode.
* Added verbose logs option to README.
This commit is contained in:
Shehab Mohsen
2023-01-09 04:24:26 -05:00
committed by GitHub
parent 0ef42a79d0
commit 787e14727a
3 changed files with 8 additions and 2 deletions
+3
View File
@@ -64,6 +64,9 @@ NEXT_PUBLIC_APP_URL=https://app.animethemes.moe
; Set to any truthy value to activate staging mode.
; In staging mode a warning banner is displayed at the top of the page.
NEXT_PUBLIC_STAGING=true
; To enable verbose logging.
NEXT_PUBLIC_VERBOSE_LOGS=true
```
For more information on environment variables see the [Next.js documentation](https://nextjs.org/docs/basic-features/environment-variables).
+3
View File
@@ -24,6 +24,8 @@ const AUDIO_URL = process.env.NEXT_PUBLIC_AUDIO_URL;
const APP_URL = process.env.NEXT_PUBLIC_APP_URL;
const STAGING = !!process.env.NEXT_PUBLIC_STAGING;
const VERBOSE_LOGS = !!process.env.NEXT_PUBLIC_VERBOSE_LOGS;
function validateConfig() {
let isValid = true;
@@ -58,5 +60,6 @@ module.exports = {
AUDIO_URL,
APP_URL,
STAGING,
VERBOSE_LOGS,
validateConfig,
};
+2 -2
View File
@@ -1,5 +1,5 @@
import * as log from "next/dist/build/output/log";
import { STAGING } from "./config";
import { VERBOSE_LOGS } from "./config";
function info(...message: string[]) {
logIfDevelopment(log.info, ...message);
@@ -14,7 +14,7 @@ function error(...message: string[]) {
}
function logIfDevelopment(fn: (...message: string[]) => void, ...message: string[]) {
if (process.env.NODE_ENV === "development" || STAGING) {
if (process.env.NODE_ENV === "development" || VERBOSE_LOGS) {
fn(...message);
}
}