question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seek support in logging hooks

See original GitHub issue

First of all; I really like this project. It makes creating nice looking progress bars a breeze compared to other solutions that I’ve tried in the past. Nice work!

Today I ran into an issue related to loggers after upgrading to 2.0.0. I’m using a RotatingFileHandler and don’t disable existing loggers, which seems to cause issues with the internal logging in alive-progress. The following small example can be used to reproduce the issue that I’m seeing

from alive_progress import alive_bar
import logging
from logging.config import dictConfig

config = {
    "version": 1,
    "disable_existing_loggers": False,    # This causes the error
    "handlers": {"logfile": {
       "class": "logging.handlers.RotatingFileHandler",
        "filename": f"test.log",
        "maxBytes": 1000
        }
    },
    "root": {"level": "DEBUG", "handlers": ["logfile"]},
}

dictConfig(config)
logger = logging.getLogger('simple_example')

n = 1
with alive_bar(total=n) as bar:
    for i in range(n):
        logger.info(f"Currently at {i}")
        bar()

which results in the following error

on 0: --- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.7/logging/handlers.py", line 68, in emit
          if self.shouldRollover(record):
  File "/usr/lib/python3.7/logging/handlers.py", line 185, in shouldRollover
          self.stream.seek(0, 2)  #due to non-posix-compliant Windows feature
AttributeError: 'types.SimpleNamespace' object has no attribute 'seek'
Call stack:
  File "test_bar.py", line 23, in <module>
          logger.info(f"Currently at {i}")
Message: 'Currently at 0'
      Arguments: ()

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
alexistelecocommented, Nov 24, 2022

Hi, I agree with @johanjeppsson, this project is great!

I’ve been having this exact same problem too (I’m using RotatingFileHandler) and when I searched for it I discovered that it is solved! 🥳

So my only question is when the next release will be released, I’m using 2.4.1 at the moment (which pip says it’s the newer one) and it is not fixed there. I do not want to put pressure or anything, just wanted to know an approximate date if possible.

Thanks again for this incredible piece of software!

1reaction
rsalmeicommented, Aug 2, 2022

This is fixed! Should be available in the next release… 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logging Tools Walkthrough | Wood-Mizer - YouTube
Logging and forestry tools are necessary to move, roll, lift, pivot, and position logs around your sawmill and woodlot.
Read more >
log hook - Amazon.com
Perfect for dragging and stacking logs, this hookaroon helps you to work efficiently and prevents dreaded back pain from hours of tree work....
Read more >
Cant Hook - Traditional Logging Tool | STIHL USA
The STIHL cant hook is used for handling and moving logs. Its movable metal hook at one end prevents the hook from falling...
Read more >
A Complete Guide to Logging in Go with Zerolog - Better Stack
Zerolog is a high-performance Go structured logging library aimed at latency-sensitive applications where garbage collections are ...
Read more >
sirupsen/logrus: Structured, pluggable logging for Go. - GitHub
Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or ... powerful-logrus-formatter . get fileName, log's line number and the latest ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found