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

Logger object has no attribute log_level #6

Open
paulsh1957 opened this issue Feb 7, 2019 · 4 comments
Open

Logger object has no attribute log_level #6

paulsh1957 opened this issue Feb 7, 2019 · 4 comments

Comments

@paulsh1957
Copy link

After running setup.py install using Enthought's Canopy python environment on a MacBook Pro running MacOS High Sierra 10.13.6 I ran the water tutorial with the files provided. An error occurred at line 150 in quickff log.py. The error was 'AttributeError: "Logger' object has no attribute 'log_level''. This was code provided in quickff-master version 2.2.0 downloaded and run unchanged. What might be causing this error? How can I fix this error?

@lvduyfhu
Copy link
Member

lvduyfhu commented Feb 8, 2019

Thank you for reporting this error. Does this error also occur with the latest version (2.2.1)? Could you also copy the complete traceback here?

@abb58
Copy link

abb58 commented Jun 16, 2019

I too came across this error with using trunk version with running water example from tutorials.
Python Verison: Python 2.7.15rc1

Traceback (most recent call last):
  File "qff-derive.py", line 29, in <module>
    with log.section('INIT', 2, timer='Initialization'):
  File "/usr/local/lib/python2.7/dist-packages/quickff/log.py", line 88, in __enter__
    if self.new_label!=self.old_label and self.logger.log_level>0:
AttributeError: 'Logger' object has no attribute 'log_level'

@abb58
Copy link

abb58 commented Jun 16, 2019

I too came across this error with using trunk version with running water example from tutorials.
Python Verison: Python 2.7.15rc1

Traceback (most recent call last):
  File "qff-derive.py", line 29, in <module>
    with log.section('INIT', 2, timer='Initialization'):
  File "/usr/local/lib/python2.7/dist-packages/quickff/log.py", line 88, in __enter__
    if self.new_label!=self.old_label and self.logger.log_level>0:
AttributeError: 'Logger' object has no attribute 'log_level'

Initialization of log_level attribute to 0 (quickff/log.py) in the class Logger did the trick

         self.add_blank_line = False
         self.timetable = []
+        self.log_level = 0

@lvduyfhu
Copy link
Member

lvduyfhu commented Nov 9, 2020

Initialization of the log level is taken care of by the first line of Logger.init, i.e. self.set_level(level) . Furthermore, to import the logger in a QuickFF script, one has to import a pre-initialized instance of Logger. This means that you should NOT do

from quickff.log import Logger
log = Logger('high')

but instead

from quickff.log import log
log.set_level('high')

You can offcourse skip the second line if you are satisfied with the default log_level (i.e. medium). In the tutorials from the online documentation we do not discuss the import statements (which is were the QuickFF logger is initialized as discussed above). If you have a look at the intire script qff-derive.py (which you can decollapse from the documentation page, eg. http://molmod.github.io/QuickFF/tu.html#tutorial-2-water), you will see that there is indeed a line from quickff.log import log.

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