Skip to content
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

Error with logging, Style not defined #51

Open
joeadam opened this issue Apr 9, 2015 · 5 comments
Open

Error with logging, Style not defined #51

joeadam opened this issue Apr 9, 2015 · 5 comments

Comments

@joeadam
Copy link

joeadam commented Apr 9, 2015

Using lantz 0.3 on Windows (Python 3.4.3 :: Anaconda 2.2.0 (32-bit).

When I try to use logging,

from lantz.log import log_to_screen, DEBUG
log_to_screen(DEBUG)

I get an error on every log print

--- Logging error ---
Traceback (most recent call last):
File "C:\Anaconda3\lib\logging__init__.py", line 978, in emit
msg = self.format(record)
File "C:\Anaconda3\lib\logging__init__.py", line 828, in format
return fmt.format(record)
File "C:\Anaconda3\lib\site-packages\lantz\log.py", line 148, in color_format
parts[0] = bef + self.colorize(dur, record) + aft
File "C:\Anaconda3\lib\site-packages\lantz\log.py", line 136, in colorize
return color + message + Style.RESET_ALL
NameError: name 'Style' is not defined
Call stack:
File "k2308.py", line 88, in
print(inst.output_enable[1])
File "C:\Anaconda3\lib\site-packages\lantz\driver.py", line 355, in exit
self.finalize()
File "C:\Anaconda3\lib\site-packages\lantz\messagebased.py", line 332, in fina
lize
super().finalize()
File "C:\Anaconda3\lib\site-packages\lantz\action.py", line 129, in call
instance.log_info('{} returned {}', name, out)
File "C:\Anaconda3\lib\site-packages\lantz\driver.py", line 304, in log_info
self.log(logging.INFO, msg, _args, *_kwargs)
File "C:\Anaconda3\lib\site-packages\lantz\driver.py", line 296, in log
logger.log(level, msg, *args, extra=self.log_extra)
Message: '{} returned {}'
Arguments: ('finalize', None)

If I import colorama manually, it imports fine, and Style is present.

@hgrecco
Copy link
Contributor

hgrecco commented Apr 13, 2015

Thanks for the report. We are anyway reworking but I will try to fix it before if I have some time.

@ntvandehey
Copy link

Joeadam-
The same problem was driving me nuts for hours, trying to figure out if had installed something wrong. I see you say "If I import colorama manually, it imports fine, and Style is present."
What exactly do you do to import colorama manually? Are you running through the tutorial?
Thanks.

@ntvandehey
Copy link

figured it out...

insert this in log.py, just after "import threading" (line 19 for me)

import colorama
from colorama import Fore, Back, Style

@joeadam
Copy link
Author

joeadam commented Apr 24, 2015

Fixes it for me as well

From: ntvandehey [mailto:notifications@github.com]
Sent: 16 April 2015 22:08
To: LabPy/lantz
Cc: Joe Adam
Subject: Re: [lantz] Error with logging, Style not defined (#51)

figured it out...

insert this in log.py, just after "import threading" (line 19 for me)

import colorama

from colorama import Fore, Back, Style


Reply to this email directly or view it on GitHubhttps://github.com//issues/51#issuecomment-93839936.

Joseph Adam, Technology Developer

Sentec Ltd phone: +44(0) 1223 303800
5 The Westbrook Centre fax: +44(0) 1223 303801
Milton Road
Cambridge email: jadam@sentec.co.uk
CB4 1YG, UK web: www.sentec.co.uk

This email is confidential. If you have received it in error, please notify Sentec Ltd UK at postmaster@sentec.co.uk immediately,
delete it from your system and note that you may not copy, distribute or use its contents.

Sentec Limited is registered at the above address UK Company Number 3452194.

@ghost
Copy link

ghost commented Aug 23, 2016

Hello,
I have got the same problem and your solution fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants