nitro icon indicating copy to clipboard operation
nitro copied to clipboard

feat: Add `NITRO_MIN_LOG_LEVEL` compiler flag

Open mrousavy opened this issue 3 months ago • 2 comments

Adds the compiler flag NITRO_MIN_LOG_LEVEL.

This flag can be used to set the minimum log level for the NitroLogger - if it is set to 0 (Debug), all logs will be visible. If it is set to 2 (Warning) (the default), only warnings and errors will be visible, and debug-/info-logs will be dropped.

This flag can and should be set in your App's Podfile/CMake file. If not set, 2 will be the default. In the Nitro Example app we set it to 0.

  • Fixes https://github.com/mrousavy/nitro/issues/883

mrousavy avatar Sep 18 '25 09:09 mrousavy

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
nitro-docs Skipped Skipped Sep 18, 2025 9:06am

vercel[bot] avatar Sep 18 '25 09:09 vercel[bot]

Ah I forgot, since we are checking this in a Pod (and especially in a header), multiple pods all include this and run this check. So we need a way to add this flag to each pod, which is kinda ugly. Like this:

post_install do |installer|
  installer.pods_project.targets.each do |t|
    next unless t.name == 'YourPodName' # the pod target, not your app target
    t.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'LOG_LEVEL=2' # 0..3
      # or for C++ specifically:
      config.build_settings['OTHER_CPLUSPLUSFLAGS'] ||= ['$(inherited)']
      config.build_settings['OTHER_CPLUSPLUSFLAGS'] << '-DLOG_LEVEL=2'
    end
  end
end

I don't like that at all. I could move it into nativeLog, then it's only defined & checked once in the Nitro Modules core library

mrousavy avatar Sep 18 '25 09:09 mrousavy