0

Im runnin a python script within my django app.

import logging,os,shelve

def logging_setup(app='default'):
    """ basic logging setup """
    logfile = '/var/log/folder/'+app+'.log'

    logger = logging.getLogger(app)
    hdlr = logging.FileHandler(logfile)
    formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr)
    logger.setLevel(logging.DEBUG)

    return loggerah man ive been slammed

However when I call this from within my code I get ..

    2014-11-26 15:24:56,977 [ERROR] 'ProcessAwareLogger' object is not callable
Traceback (most recent call last):
  File "/staging/nx/views.py", line 40, in nx_input
    crawl_data = nx_runner.main(device=serializer.data["input"])
  File "/staging/nx/runner.py", line 101, in main
    self.import_to_mongo()
  File "/staging/nx/runner.py", line 69, in import_to_mongo
    mongo_import.import_all_devices()
  File "/staging/nx/parser.py", line 194, in import_all_devices
    device_model = self.import_device(d)
  File "/staging/nx/parser.py", line 158, in import_device
    self.dstoreimport(str(aggrs))
TypeError: 'ProcessAwareLogger' object is not callable

I calling it via ....

self.dstoreimport = logging_setup(app="dataImportMongo")
self.dstoreimport(str(aggrs))

Any ideas ..?

1
  • We can't help without seeing exactly how you are "calling this from within the code" and the full traceback. Commented Nov 26, 2014 at 15:25

1 Answer 1

4

instead of

self.dstoreimport(str(aggrs))

try

self.dstoreimport.info(str(aggrs))

instead.

self.dstoreimport is a logger object, and therefore not callable (hence the error). You need to call the instance method of that object (in this example, I'm using info(), but you could easily call debug(), error(), etc. depending on your need) instead.

Sign up to request clarification or add additional context in comments.

1 Comment

sometimes its the easiest of things that can catch up out. : ) Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.