Skip to content

Commit 970af6b

Browse files
authored
Merge pull request #2753 from ShaneHarvey/log-mongoengine-version
Log MongoEngine version when connecting to the server
2 parents ac8ba50 + d17a081 commit 970af6b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mongoengine/connection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
from pymongo import MongoClient, ReadPreference, uri_parser
44
from pymongo.database import _check_name
55

6+
# DriverInfo was added in PyMongo 3.7.
7+
try:
8+
from pymongo.driver_info import DriverInfo
9+
except ImportError:
10+
DriverInfo = None
11+
12+
import mongoengine
613
from mongoengine.pymongo_support import PYMONGO_VERSION
714

815
__all__ = [
@@ -320,6 +327,10 @@ def _clean_settings(settings_dict):
320327
# alias and remove the database name and authentication info (we don't
321328
# care about them at this point).
322329
conn_settings = _clean_settings(raw_conn_settings)
330+
if DriverInfo is not None:
331+
conn_settings.setdefault(
332+
"driver", DriverInfo("MongoEngine", mongoengine.__version__)
333+
)
323334

324335
# Determine if we should use PyMongo's or mongomock's MongoClient.
325336
if "mongo_client_class" in conn_settings:

0 commit comments

Comments
 (0)