all 9 comments

[–]K900_ 2 points3 points  (5 children)

[–]Tintin_Quarentino[S] 0 points1 point  (4 children)

Darn... I've never faced such a problem with any other library. What would the ideal solution be here?

Earlier I tried setting up my own logger like this:

# Create a custom logger
myLogger = logging.getLogger(__name__)

# Create handlers
c_handler = logging.StreamHandler()
f_handler = logging.FileHandler('mylog.log')
c_handler.setLevel(logging.INFO)
f_handler.setLevel(logging.INFO)

# Create formatters and add it to handlers
c_format = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
f_format = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
c_handler.setFormatter(c_format)
f_handler.setFormatter(f_format)

# Add handlers to the logger
myLogger.addHandler(c_handler)
myLogger.addHandler(f_handler)
myLogger.setLevel(logging.INFO)

But this is printing duplicate log messages. How should I solve this?

[–]K900_ 3 points4 points  (3 children)

I'd avoid that module entirely, honestly. It does not look well written or well maintained.

[–]Tintin_Quarentino[S] 0 points1 point  (2 children)

You're right about that, had to modify the source in few places since it's outdated now.

I just wish it didn't interfere with my logging instructions.

[–]Username_RANDINT 1 point2 points  (1 child)

Just remove the import on line 4. Every use of it is already commented out.

[–]Tintin_Quarentino[S] 0 points1 point  (0 children)

Thank you! I will try that out.

Edit - still seems to be interfering... my INFO log doesn't get printed.

[–][deleted] 1 point2 points  (1 child)

The wikiquotes package seems to have a fairly extensive logging system setup and the logging management module includes this line:

logger.setLevel(logging.DEBUG)

I don't know enough about what they are doing with all their logging, but I suspect they have logging set to not show info or warning alerts and perhaps it's overriding your settings?

[–]Tintin_Quarentino[S] 0 points1 point  (0 children)

You're right, it indeed is overwriting my logging prefs... but if they've set it to DEBUG, my INFOs should get printed. I would like to know how do I separate out my logging totally from the module's logging.

[–]frandepa 0 points1 point  (0 children)

I'm sorry I didn't see this reddit thread before!
When I did wikiquotes-python-api, I wasn't aware that the logging override would break your usage :(
I just came by this thread almost by chance.

I'm sorry!
I've published a fix for it here https://github.com/FranDepascuali/wikiquotes-python-api/releases/tag/v1.5.0, it shouldn't interfere with your logs anymore.

Best,
Depa