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

disable logging when taking picture #1074

Open
LeifSec opened this issue Jul 22, 2024 · 5 comments
Open

disable logging when taking picture #1074

LeifSec opened this issue Jul 22, 2024 · 5 comments

Comments

@LeifSec
Copy link

LeifSec commented Jul 22, 2024

Following issue I want to switch off logging / set logging level to ERROR for calling a function

camera.switch_mode_and_capture_image(
                camera_config=self.__settings.still_configuration,
                name="main",
                wait=None,
                signal_function=None)

.
So I did:

if "picamera2" not in logging.Logger.manager.loggerDict.keys():
            raise ValueError("not in tt")
logger = logging.getLogger("picamera2")
logger.setLevel(logging.ERROR)
camera.switch_mode_and_capture_image(....
logger.setLevel(old_level)

Unfortunately there is still this INFO level logging:

163:48:59.073898409] [27530]  INFO Camera camera.cpp:1183 configuring streams: (0) 1536x864-BGR888 (1) 4608x2592-SBGGR10_CSI2P
[163:48:59.097958056] [27500]  INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
[163:48:59.516137626] [27530]  INFO Camera camera.cpp:1183 configuring streams: (0) 1536x864-XBGR8888 (1) 2304x1296-SBGGR10_CSI2P
[163:48:59.525447463] [27500]  INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA

I am using imx708 camera and latest Raspberian 12 software.

@davidplowman
Copy link
Collaborator

Yes, this is all libcamera logging and it can be quite chatty. It might be easiest just to put something like export LIBCAMERA_LOG_LEVELS=*:3 in your .bashrc...

@LeifSec
Copy link
Author

LeifSec commented Jul 22, 2024

export LIBCAMERA_LOG_LEVELS=*:3works - thank you very much. But as I need it in the code (to disable it just for that call of switch_mode_and_capture_image ) I need something like:

os.environ["LIBCAMERA_LOG_LEVELS"] = "*:3"
camera.switch_mode_and_capture_image(...`
os.environ["LIBCAMERA_LOG_LEVELS"] = "*:old_level"

But this does not work.

@davidplowman
Copy link
Collaborator

Yes, libcamera probably only reads that environment variable when it starts up. So far as I know, there's no Python interface to libcamera's logging system after that. So I don't really have a workaround for you there. Can you say which of the logging messages are actually useful? I'm wondering whether you can turning them all off, and add your own logging for your application.

@LeifSec
Copy link
Author

LeifSec commented Jul 22, 2024

Maybe also INFO Camera camera.cpp:1183 configuring streams: ( ... is usefull in some cases.

But I am taking pictures for two reasons

  • My main application at high resolution at lower frequency.
  • For a live stream of pictures (to avoid problem with video stream and taking pictures) at lower resolution and with high frequency.

For both I want to get error messages. For the main application maybe also info messages are usefull. But for the live stream they info messages are spamming my log.

@davidplowman
Copy link
Collaborator

Unfortunately, so far as I know, there's no way to adjust the logging at runtime. But note that by choosing the logging level appropriately, you can still get warnings and errors. When it comes to configuring streams, you can easily print out the details of the configuration you got, for the purpose of double-checking what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants