Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable logging when using makeEnvPublic #108

Open
gregorybolkenstijn opened this issue Mar 12, 2024 · 2 comments · May be fixed by #143
Open

Option to disable logging when using makeEnvPublic #108

gregorybolkenstijn opened this issue Mar 12, 2024 · 2 comments · May be fixed by #143
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@gregorybolkenstijn
Copy link

gregorybolkenstijn commented Mar 12, 2024

When using makeEnvPublic in next.config.js:

const { makeEnvPublic } = require('next-runtime-env')

makeEnvPublic([
  'API_BASE_URL',
])

It logs ✓ Prefixed environment variable 'API_BASE_URL' (next-runtime-env) on every server start. Both in local development mode and on production environments this creates a lot of (duplicate) noise in the logs. An option to disable this would be a nice and simple addition:

makeEnvPublic([
  'API_BASE_URL',
], {
  loglevel: 'silent' // Other options could 'warn', 'info'
})
@HofmannZ
Copy link
Member

@gregorybolkenstijn, this would be a great addition! Happy to review a pull request for this.

@HofmannZ HofmannZ added enhancement New feature or request good first issue Good for newcomers labels Mar 26, 2024
@Ghastly2001
Copy link

I cloned the repo but didn't find the code for it. Anyway, maybe you should try conditional logging. Instead of completely disabling the log, you can get env variables to conditionally log only during development.

Like this:

const { makeEnvPublic } = require('next-runtime-env')

const isDevelopment = process.env.NODE_ENV === 'development'

makeEnvPublic([
  'API_BASE_URL',
], {
  silent: !isDevelopment
})

if (isDevelopment) {
  console.log('✓ Prefixed environment variable \'API_BASE_URL\' (next-runtime-env)')
}

@MaxAltena MaxAltena linked a pull request Jun 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants