@@ -275,8 +275,8 @@ For example:
275275 raise gaierror(" Unexpected socket address %r " % socket_address)
276276
277277 driver = GraphDatabase.driver(" neo4j://example.com:9999" ,
278- auth = (" neo4j" , " password" ),
279- resolver = custom_resolver)
278+ auth = (" neo4j" , " password" ),
279+ resolver = custom_resolver)
280280
281281
282282:Default: :const: `None `
@@ -541,9 +541,9 @@ Name of the database to query.
541541
542542
543543.. py :attribute :: neo4j.DEFAULT_DATABASE
544- :noindex:
544+ :noindex:
545545
546- This will use the default database on the Neo4j instance.
546+ This will use the default database on the Neo4j instance.
547547
548548
549549.. Note ::
@@ -558,9 +558,10 @@ Name of the database to query.
558558
559559.. code-block :: python
560560
561- from neo4j import GraphDatabase
562- driver = GraphDatabase.driver(uri, auth = (user, password))
563- session = driver.session(database = " system" )
561+ from neo4j import GraphDatabase
562+
563+ driver = GraphDatabase.driver(uri, auth = (user, password))
564+ session = driver.session(database = " system" )
564565
565566
566567:Default: ``neo4j.DEFAULT_DATABASE ``
@@ -593,9 +594,10 @@ context of the impersonated user. For this, the user for which the
593594
594595.. code-block :: python
595596
596- from neo4j import GraphDatabase
597- driver = GraphDatabase.driver(uri, auth = (user, password))
598- session = driver.session(impersonated_user = " alice" )
597+ from neo4j import GraphDatabase
598+
599+ driver = GraphDatabase.driver(uri, auth = (user, password))
600+ session = driver.session(impersonated_user = " alice" )
599601
600602
601603:Default: :const: `None `
@@ -740,8 +742,8 @@ Example:
740742 def set_person_name (tx , node_id , name ):
741743 query = " MATCH (a:Person) WHERE id(a) = $id SET a.name = $name"
742744 result = tx.run(query, id = node_id, name = name)
743- info = result.consume()
744- # use the info for logging etc.
745+ summary = result.consume()
746+ # use the summary for logging etc.
745747
746748 .. _managed-transactions-ref :
747749
@@ -1350,6 +1352,49 @@ following code:
13501352 ...
13511353
13521354
1355+ *******
1356+ Logging
1357+ *******
1358+
1359+ The driver offers logging for debugging purposes. It is not recommended to
1360+ enable logging for anything other than debugging. For instance, if the driver is
1361+ not able to connect to the database server or if undesired behavior is observed.
1362+
1363+ There are different ways of enabling logging as listed below.
1364+
1365+ Simple Approach
1366+ ===============
1367+
1368+ .. autofunction :: neo4j.debug.watch(*logger_names, level=logging.DEBUG, out=sys.stderr, colour=False)
1369+
1370+ Context Manager
1371+ ===============
1372+
1373+ .. autoclass :: neo4j.debug.Watcher(*logger_names, default_level=logging.DEBUG, default_out=sys.stderr, colour=False)
1374+ :members:
1375+ :special-members: __enter__, __exit__
1376+
1377+ Full Controll
1378+ =============
1379+
1380+ .. code-block :: python
1381+
1382+ import logging
1383+ import sys
1384+
1385+ # create a handler, e.g. to log to stdout
1386+ handler = logging.StreamHandler(sys.stdout)
1387+ # configure the handler to your liking
1388+ handler.setFormatter(logging.Formatter(
1389+ " %(threadName)s (%(thread)d ) %(asctime)s %(message)s "
1390+ ))
1391+ # add the handler to the driver's logger
1392+ logging.getLogger(" neo4j" ).addHandler(handler)
1393+ # make sure the logger logs on the desired log level
1394+ logging.getLogger(" neo4j" ).setLevel(logging.DEBUG )
1395+ # from now on, DEBUG logging to stderr is enabled in the driver
1396+
1397+
13531398*********
13541399Bookmarks
13551400*********
0 commit comments