mirror of
https://github.com/AnimeThemes/animethemes-web.git
synced 2026-07-11 01:24:31 +02:00
chore: Decouple verbose logging from staging (#160)
* Decoupled verbose logs from staging mode. * Added verbose logs option to README.
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user