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

Use of Logger #26

Open
decalage2 opened this issue Aug 28, 2015 · 1 comment
Open

Use of Logger #26

decalage2 opened this issue Aug 28, 2015 · 1 comment

Comments

@decalage2
Copy link
Owner

Originally reported by: Anonymous


Hello:

When importing oletools.olevba while using a pre-defined logger for my application, I noted some anomalous behavior. It seemed that after invoking the VBA_Parser, any entry I was writing to my logfile in my application was also being written to STDERR as well.

To replicate this issue, I produced the following code.

#!python

#!/usr/bin/python

import sys
import logging
from oletools.olevba import VBA_Parser, VBA_Scanner
from cloghandler import ConcurrentRotatingFileHandler

# set up logger for application
dbg_h = logging.getLogger('dbg_log')
dbglog = '%s' % 'dbg.log'
dbg_rotateHandler = ConcurrentRotatingFileHandler(dbglog, "a")
dbg_h.addHandler(dbg_rotateHandler)
dbg_h.setLevel(logging.ERROR)

# read some document as a buffer
buff = sys.stdin.read()

# generate issue
dbg_h.error('Before call to module....')
vba = VBA_Parser('somedoc.doc', data=buff)
dbg_h.error('After call to module....')

When I run this, I get the following...

cat somedocument.doc | ./replicate.py
ERROR:dbg_log:After call to module....

My last dbg_h logger write attempt is getting output to the console as well as getting written to my dbg.log file. I see in your TODO you have a few comments surrounding logging. If it has not been considered already, I would like to suggest making that an option a caller can disable.


@decalage2
Copy link
Owner Author

Original comment by Philippe Lagadec (Bitbucket: decalage, GitHub: decalage2):


Indeed I need to cleanup the logging code to disable it properly by default.

Module logging should not interfere with the main application's logging, unless explicitly enabled to do so.

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

No branches or pull requests

1 participant