Skip to content

Commit 7d7c42a

Browse files
committed
Merge branch 'add_logger' of https://github.com/jverswijver/datajoint-python into remove_checksum
2 parents 267095f + a52b789 commit 7d7c42a

19 files changed

+118
-35
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### 0.13.6 -- TBD
44
* Add - Config option to set threshold for when to stop using checksums for filepath stores. PR #1025
5+
* Add - unified package level logger for package
6+
* Update - swap various datajoint messages, warnings, ect. to use the new logger.
57

68
### 0.13.5 -- May 19, 2022
79
* Update - Import ABC from collections.abc for Python 3.10 compatibility

LNX-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
interval: 1s
3333
fakeservices.datajoint.io:
3434
<<: *net
35-
image: datajoint/nginx:v0.1.1
35+
image: datajoint/nginx:v0.2.1
3636
environment:
3737
- ADD_db_TYPE=DATABASE
3838
- ADD_db_ENDPOINT=db:3306

datajoint/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"key_hash",
5353
]
5454

55+
from .logging import logger
5556
from .version import __version__
5657
from .settings import config
5758
from .connection import conn, Connection

datajoint/autopopulate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# noinspection PyExceptionInherit,PyCallingNonCallable
1414

15-
logger = logging.getLogger(__name__)
15+
logger = logging.getLogger(__name__.split(".")[0])
1616

1717

1818
# --- helper functions for multiprocessing --
@@ -275,7 +275,7 @@ def _populate1(
275275
if jobs is not None:
276276
jobs.complete(self.target.table_name, self._job_key(key))
277277
else:
278-
logger.info("Populating: " + str(key))
278+
logger.debug("Populating: " + str(key))
279279
self.__class__._allow_insert = True
280280
try:
281281
make(dict(key), **(make_kwargs or {}))

datajoint/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .hash import uuid_from_buffer
1818
from .plugin import connection_plugins
1919

20-
logger = logging.getLogger(__name__)
20+
logger = logging.getLogger(__name__.split(".")[0])
2121
query_log_max_length = 300
2222

2323

@@ -184,7 +184,7 @@ def __init__(self, host, user, password, port=None, init_fun=None, use_tls=None)
184184
self.conn_info["ssl_input"] = use_tls
185185
self.conn_info["host_input"] = host_input
186186
self.init_fun = init_fun
187-
print("Connecting {user}@{host}:{port}".format(**self.conn_info))
187+
logger.info("Connecting {user}@{host}:{port}".format(**self.conn_info))
188188
self._conn = None
189189
self._query_cache = None
190190
connect_host_hook(self)
@@ -339,7 +339,7 @@ def query(
339339
except errors.LostConnectionError:
340340
if not reconnect:
341341
raise
342-
warnings.warn("MySQL server has gone away. Reconnecting to the server.")
342+
logger.warning("MySQL server has gone away. Reconnecting to the server.")
343343
connect_host_hook(self)
344344
if self._in_transaction:
345345
self.cancel_transaction()

datajoint/declare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def match_type(attribute_type):
7575
)
7676

7777

78-
logger = logging.getLogger(__name__)
78+
logger = logging.getLogger(__name__.split(".")[0])
7979

8080

8181
def build_foreign_key_parser_old():
@@ -207,7 +207,7 @@ def compile_foreign_key(
207207
)
208208

209209
if obsolete:
210-
warnings.warn(
210+
logger.warning(
211211
'Line "{line}" uses obsolete syntax that will no longer be supported in datajoint 0.14. '
212212
"For details, see issue #780 https://github.com/datajoint/datajoint-python/issues/780".format(
213213
line=line

datajoint/diagram.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
import re
33
import functools
44
import io
5-
import warnings
5+
import logging
66
import inspect
77
from .table import Table
88
from .dependencies import unite_master_parts
9+
from .user_tables import Manual, Imported, Computed, Lookup, Part
10+
from .errors import DataJointError
11+
from .table import lookup_class_name
12+
13+
logger = logging.getLogger(__name__.split(".")[0])
914

1015
try:
1116
from matplotlib import pyplot as plt
@@ -21,10 +26,6 @@
2126
except:
2227
diagram_active = False
2328

24-
from .user_tables import Manual, Imported, Computed, Lookup, Part
25-
from .errors import DataJointError
26-
from .table import lookup_class_name
27-
2829

2930
user_table_classes = (Manual, Lookup, Computed, Imported, Part)
3031

@@ -63,7 +64,7 @@ class Diagram:
6364
"""
6465

6566
def __init__(self, *args, **kwargs):
66-
warnings.warn(
67+
logger.warning(
6768
"Please install matplotlib and pygraphviz libraries to enable the Diagram feature."
6869
)
6970

datajoint/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818
from .declare import CONSTANT_LITERALS
1919

20-
logger = logging.getLogger(__name__)
20+
logger = logging.getLogger(__name__.split(".")[0])
2121

2222

2323
class QueryExpression:

datajoint/fetch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from functools import partial
22
from pathlib import Path
3-
import warnings
3+
import logging
44
import pandas
55
import itertools
66
import re
@@ -12,6 +12,8 @@
1212
from .settings import config
1313
from .utils import safe_write
1414

15+
logger = logging.getLogger(__name__.split(".")[0])
16+
1517

1618
class key:
1719
"""
@@ -209,7 +211,7 @@ def __call__(
209211
)
210212

211213
if limit is None and offset is not None:
212-
warnings.warn(
214+
logger.warning(
213215
"Offset set, but no limit. Setting limit to a large number. "
214216
"Consider setting a limit explicitly."
215217
)

datajoint/heading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .attribute_adapter import get_adapter, AttributeAdapter
1515

1616

17-
logger = logging.getLogger(__name__)
17+
logger = logging.getLogger(__name__.split(".")[0])
1818

1919
default_attribute_properties = (
2020
dict( # these default values are set in computed attributes

0 commit comments

Comments
 (0)