Raspberry Pi Python, How to disable logging

I am using a raspberry Pi Zero W and a Python program to monitor the system health.
I would like to disable the logging or at least move it to CRITICAL using the setlevel command but I cannot figure out how to call it.

client = cayenne.client.CayenneMQTTClient()


if you remove the import logging and the loglevel=logging.INFO, it should work.

First let me thank you for taking the time to reply.

I tried that first. Some of the logging disappeared but the “PUB xxxx” data still scrolls to the screen.

Below is the top of my code:

import os
import smbus2
import time
import datetime
import io
import cayenne.client
import psutil

#Cayenne credentials
MQTT_USERNAME = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
MQTT_PASSWORD = “yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy”
MQTT_CLIENT_ID = “zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz”

client = cayenne.client.CayenneMQTTClient()

i have done the same right now for testing and it does not show anything for me in my terminal when executed.

I am using a Pi Zero W with a minimum distribution on it (no desktop). The SSH terminal (on my PC) that I log in too, does not show anything after I launch the python code. But the display monitor I have attached to the zero W (micro-usb port attached for typing) streams every mqtt wrte that I send to Cayenne. Does this help explain what I see?

on your pi edit the client.py file Cayenne-MQTT-Python/client.py at master · myDevicesIoT/Cayenne-MQTT-Python · GitHub and comment all the log.info files.

Thank you sir. That is what I thought I needed to do, I appreciate the help.

Any idea where that file is located, I went poking around and I believe I found a .egg file but do not think I saw where the .py file was stored.

it is located in /Cayenne-MQTT-Python/cayenne

Much appreciated and I hope you have a wonderful day/evening. Thanks again.

1 Like

OK… Not sure where I got it but I actually have an old revision of the client.py

They used the print command, guess I will load the new file and try again.

Full path to the file is here:

I appreciate the help.

1 Like