Skip to content

Commit 684d69d

Browse files
authored
Move lock acquire/release log from INFO to DEBUG (#95)
1 parent 30ef634 commit 684d69d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/filelock/_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def acquire(self, timeout=None, poll_intervall=0.05):
136136
self._acquire()
137137

138138
if self.is_locked:
139-
_LOGGER.info("Lock %s acquired on %s", lock_id, lock_filename)
139+
_LOGGER.debug("Lock %s acquired on %s", lock_id, lock_filename)
140140
break
141141
elif 0 <= timeout < time.time() - start_time:
142142
_LOGGER.debug("Timeout on acquiring lock %s on %s", lock_id, lock_filename)
@@ -175,7 +175,7 @@ def release(self, force=False):
175175
_LOGGER.debug("Attempting to release lock %s on %s", lock_id, lock_filename)
176176
self._release()
177177
self._lock_counter = 0
178-
_LOGGER.info("Lock %s released on %s", lock_id, lock_filename)
178+
_LOGGER.debug("Lock %s released on %s", lock_id, lock_filename)
179179

180180
def __enter__(self):
181181
self.acquire()

tests/test_filelock.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import unicode_literals
22

3+
import logging
34
import sys
45
import threading
56

@@ -9,7 +10,8 @@
910

1011

1112
@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
12-
def test_simple(lock_type, tmp_path):
13+
def test_simple(lock_type, tmp_path, caplog):
14+
caplog.set_level(logging.DEBUG)
1315
lock_path = tmp_path / "a"
1416
lock = lock_type(str(lock_path))
1517

@@ -18,6 +20,14 @@ def test_simple(lock_type, tmp_path):
1820
assert lock is locked
1921
assert not lock.is_locked
2022

23+
assert caplog.messages == [
24+
"Attempting to acquire lock {} on {}".format(id(lock), lock_path),
25+
"Lock {} acquired on {}".format(id(lock), lock_path),
26+
"Attempting to release lock {} on {}".format(id(lock), lock_path),
27+
"Lock {} released on {}".format(id(lock), lock_path),
28+
]
29+
assert [r.levelno for r in caplog.records] == [logging.DEBUG, logging.DEBUG, logging.DEBUG, logging.DEBUG]
30+
2131

2232
@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
2333
def test_nested_context_manager(lock_type, tmp_path):

whitelist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
autoclass
22
autodoc
33
autosectionlabel
4+
caplog
45
creat
56
exc
67
fcntl
78
filelock
89
fmt
910
intersphinx
1011
intervall
12+
levelno
1113
lk
1214
lockfile
1315
msvcrt

0 commit comments

Comments
 (0)