enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 188 forks source link

weather module ignores log_level option. #706

Closed crocket closed 5 years ago

crocket commented 5 years ago
status.register("weather",
                format="{icon} {current_temp}{temp_unit}"
                +"  {wind_speed}{wind_unit} 懲 {humidity}%  {uv_index}"
                +" {update_error}",
                interval=1800,
                log_level=60,
                color_icons={'Fair': ('', '#ffcc00'),
                             'Cloudy': ('', '#f8f8ff'),
                             'Partly Cloudy': ('', '#f8f8ff'),
                             'Fog': ('', '#949494'), 'Sunny': ('', '#ffff00'),
                             'default': ('', None), 'Rainy': ('', '#cbd2c0'),
                             'Thunderstorm': ('', '#cbd2c0'),
                             'Snow': ('流', '#ffffff')},
                backend=weathercom.Weathercom(
                    location_code="XXXXXX",
                    update_error="",
                    units="metric"))

I want only CRITICAL errors to be logged, but weather module keeps logging HTTP errors.

2019-01-29 15:15:34,533 [ERROR   ][i3pystatus.weather.weathercom.Weathercom 334] Uncaught error occurred while checking weather. Exception follows:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/i3pystatus/weather/weathercom.py", line 206, in check_weather
    self.parser.get_weather_data(self.forecast_url)
  File "/usr/lib64/python3.6/site-packages/i3pystatus/weather/weathercom.py", line 31, in get_weather_data
    html = content.read().decode(charset)
  File "/usr/lib64/python3.6/http/client.py", line 456, in read
    return self._readall_chunked()
  File "/usr/lib64/python3.6/http/client.py", line 563, in _readall_chunked
    chunk_left = self._get_chunk_left()
  File "/usr/lib64/python3.6/http/client.py", line 546, in _get_chunk_left
    chunk_left = self._read_next_chunk_size()
  File "/usr/lib64/python3.6/http/client.py", line 506, in _read_next_chunk_size
    line = self.fp.readline(_MAXLINE + 1)
  File "/usr/lib64/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib64/python3.6/ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib64/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib64/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer
chestm007 commented 5 years ago

do you mind trying using logging.CRITICAL as the log level or at the very least 50 I'm not sure why the loglevel is being ignored - the only idea i have is that due too 60 not actually being a log level, its just being ignored

crocket commented 5 years ago

I tried log_level=50, but it is ignored, too.

terminalmage commented 5 years ago

From the documentation

Note

The log level must be set separately in both the module and backend contexts.

You will need to pass a log_level separately to the weather.Weathercom instance, as in the config example.