Questions tagged [loguru]

For questions related to the logging library for Python. It can be combined with the tag [python].

Loguru is a Python logging library. It has a variety of useful features that solve the drawbacks of standard loggers.

Some Features

From https://loguru.readthedocs.io/en/stable/overview.html#features

  • Ready to use out of the box without boilerplate
  • No Handler, no Formatter, no Filter: one function to rule them all
  • Easier file logging with rotation / retention / compression
  • Exceptions catching within threads or main
  • Asynchronous, Thread-safe, Multiprocess-safe
  • Fully descriptive exceptions
  • Better datetime handling

Useful links

41 questions
0
votes
1 answer

Python logging with Loguru - passing correlation id to child thread

I would like to log correlation id in every log messages via Loguru. I tried to use logger.contextualize(correlation_id=id). It works in the parent thread but not the child thread. How do I get the correlation id to be logged in the child thread…
0
votes
0 answers

Importing loguru in Python 3.11 ModuleNotFound

I already installed loguru and everything looks fine. However, everytime I try to import it, I get the message ModuleNotfound. I have Python 3.11, and this is only happening with this package. Does anyone knows what is the problem and how can i…
0
votes
1 answer

Get rid of excessive logs

I'm trying to remove excessive logs in my framework. During test run lot's of useless log records are shown in the console, e.g. logs of urllib3, faker and so on. I'm using Loguru library (tried 'logging' library too -- same result). Already…
Krematory
  • 21
  • 4
0
votes
1 answer

How to handle error by myself while using Loguru

I have some sentence with custom encoded characters. when using Loguru, it raises UnicodeEncodeError because it can't encode my sentence due to those custom characters, so I hope I can handle error by myself, what should I do?
realhuhu
  • 25
  • 5
0
votes
1 answer

How to limit message length in loguru?

sometimes I log big data and sometimes I don't. If the message is large, I want to crop it, but know how much I cropped it. I want something like this: big_data = [1, 2, 3, ... 100] logger.info(f"Received data: {big_data}) Logging data: 11:20…
0
votes
0 answers

Cannot run python script that uses loguru

I couldn't find any similar SO threads, so i decided to create a new one. I'd like to use loguru in my python scripts, but i encountered a problem with running them through url http://host:port/some/dirs/script.py Running script like so gives me an…
0
votes
1 answer

loguru ModuleNotFoundError when using pyinstaller

when building EXE with pyinstaller, the resulting exe file doesn't execute and the error 'ModuleNotFoundError: No module named 'loguru'' is shown. Running the pythons script works without any issues. didn't find any solution that worked so far on…
StefD
  • 1
  • 2
0
votes
1 answer

Use Loguru logging library to log requests made in an imported file

So I have program written in a python file (main.py) that uses classes in an api wrapper file (bluerev.py). I want to use the loguru logger in main.py to collect all exceptions from the program + all requests made in the api wrapper. So the logging…
ChungaBunga
  • 116
  • 1
  • 10
0
votes
0 answers

Logging decorator

I'm using PTB library and have many handlers as: def some_handler(update, context): # Update is new data from user, context is all my data do_something() And I want to notify user if error has occured, like: def some_handler(update,…
salius
  • 918
  • 1
  • 14
  • 30
0
votes
1 answer

Python error with literals and lists in loguru: unsupported operand type(s) for +: 'NoneType' and 'list'

Working with loguru in order to write a list back to the configuration file, and received the dreaded unsupported operand type(s) for +: 'NoneType' and 'list' error. I know the error came from attempting to combine a literal and a list. I attempted…
Anoduck
  • 61
  • 6
0
votes
1 answer

Loguru callback function when an error is logged

I'm moving a desktop application from Python's standard library logging to Loguru, and want to have a text box in the user interface that contains logging information. Is there a way to hook into Loguru error-level logging which allows the log…
Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62
1 2
3