-
Notifications
You must be signed in to change notification settings - Fork 704
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
_sub_tag() could not find tag #177
Comments
It works fine on my computer... 😕 Is it this exact code snippet which is triggering the error? It looks like Loguru tries to reformat a message already formatted, which causes error as the initial formatting transformed |
I could fix it now, I need to set |
I need to remove loglevel = loglevel.replace('"', '') If I do not, the loglevel will have additional quotes. |
Yep, but it should not have failed in the first place. 😅 If you have more information on the code that generates the error, it might be useful to help resolve this. |
I am using version 0.3.2. |
Looking at the line 89 which appears on the error traceback: Line 89 in d620a11
It's called only if |
Got it! That happens if |
Sorry, I do not get your point. However, today is a new day and I have restarted my Windows 10. The problem disappeared when I removed or commented from loguru import logger
import os
logger.remove() # Remove the default logger
logfile = r'logfile.log'
loglevel = os.getenv('LOGLEVEL', 'INFO')
loglevel = loglevel.replace('"', '')
fmt='{time:YYYY:MM:DD HH:MM:SS} | {level: <8} | {name}:{function}:{line} - {message}'
logger.add(
logfile,
format=fmt,
level=loglevel
)
logger.trace ("TRACE priority message")
logger.debug ("DEBUG priority message")
logger.info ("INFO priority message")
logger.success ("SUCCESS priority message")
logger.warning ("WARNING priority message")
logger.error ("ERROR priority message")
logger.critical("CRITICAL priority message") This is very strange to me too. However, I still need to have set LOGLEVEL="TRACE" Of course, if I set the environment variable in following way, the problem will not appear: set LOGLEVEL=TRACE |
I think there was some confusion when you tried to debug this problem, this code snippet actually always worked fine. However, I think that at one time or another, you had something very slightly different that would generate the error, just a small typo: logger.add(
logfile,
format=format,
level=loglevel
) Note the Here, the "{'elapsed': datetime.timedelta(microseconds=10002), 'exception': None, 'extra': {}, 'file': (name='a.py', path='a.py'), 'function': '<module>', 'level': (name='INFO', no=20, icon='ℹ️'), 'line': 20, 'message': 'INFO priority message', 'module': 'a', 'name': '__main__', 'process': (id=100026, name='MainProcess'), 'thread': (id=140006286919296, name='MainThread'), 'time': datetime(2019, 11, 24, 9, 8, 26, 483395, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600), 'CET'))}" Later, this will raise an error, because That's why I propose to add a check inside Loguru, to ensure that the
Yes, as you taught me, the |
I have a simple program using a file as sink:
It shows the following errors:
However, if I remove the
format=fmt
line, the code works perfectly.The text was updated successfully, but these errors were encountered: