Closed nvllsvm closed 2 years ago
Dunno, I think your changes are OK, but I also think it's fine the way it is, because:
@piskvorky thoughts?
I'd keep it as-is, mostly on account of @mpenkov 's point 3). That's the reason why we use logging, so that people can configure the threshold the way they like.
While it's true there is some subjective arbitrariness in what is considered DEBUG (for developers) vs INFO (generally useful info but nothing vital), IMO "opening a database" falls squarely into INFO.
@nvllsvm why does it bother you?
Let me start by saying that I understand I'm being fairly pedantic about not liking the default of an info-level log entry. Thank you for discussing with me.
why does it bother you?
It's unexpected to have an otherwise unopinionated library output info-level statements by default. Libraries like the stdlib's sqlite3 and the popular pycopg do not output anything info-level when connecting to their respective databases. Tangentially, neither httpx not requests output info-level when making an HTTP request. These libraries delegate that responsibility to the developer using them.
For example, the only log entry output by this dict is from sqlitedict
import logging
import sqlite3
import psycopg
import requests
import sqlitedict
logging.basicConfig(level=logging.INFO)
sqlite3.connect('test.sqlite')
psycopg.connect('postgresql://somedb')
requests.get('https://github.com')
sqlitedict.SqliteDict('test.sqlitedict')
INFO:sqlitedict:opening Sqlite table 'unnamed' in 'test.sqlitedict'
That log entry is unnecessary noise in log output - especially when the output is shared with someone unfamiliar with sqlitedict or when multiple files are being used.
I know I can manually change the level of sqlitedict's logger, but then that becomes noise in the code - which results in a very slight increase in complexity for someone not familiar with sqlitedict (my team).
I also use this library in multiple, self-contained scripts so having to disable the library's opinion in each one is just one more thing I have to do.
That log entry is unnecessary noise in log output - especially when the output is shared with someone unfamiliar with sqlitedict or when multiple files are being used.
OK, that's a reasonable point.
Merged, thank you for your effort and explanation.
What Change the the database-open log from info-level to debug-level
Why It's an implementation detail that one does not need to care about while using this library.