Skip to content

Commit f851881

Browse files
authored
python: Use private logger instead of root logger (#212)
1 parent 036b46c commit f851881

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pyroscope_ffi/python/pyroscope/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from pyroscope._native import lib
88
from contextlib import contextmanager
99

10+
LOGGER = logging.getLogger(__name__)
11+
1012
class LineNo(Enum):
1113
LastInstruction = 0
1214
First = 1
@@ -41,9 +43,9 @@ def configure(
4143
if native is not None:
4244
warnings.warn("native is deprecated and not supported", DeprecationWarning)
4345

46+
LOGGER.disabled = not enable_logging
4447
if enable_logging:
45-
logger = logging.getLogger()
46-
log_level = logger.getEffectiveLevel()
48+
log_level = LOGGER.getEffectiveLevel()
4749
lib.initialize_logging(log_level)
4850

4951
lib.initialize_agent(
@@ -69,9 +71,9 @@ def shutdown():
6971
drop = lib.drop_agent()
7072

7173
if drop:
72-
logging.info("Pyroscope Agent successfully shutdown")
74+
LOGGER.info("Pyroscope Agent successfully shutdown")
7375
else:
74-
logging.warn("Pyroscope Agent shutdown failed")
76+
LOGGER.warning("Pyroscope Agent shutdown failed")
7577

7678
def add_thread_tag(thread_id, key, value):
7779
lib.add_thread_tag(thread_id, key.encode("UTF-8"), value.encode("UTF-8"))

0 commit comments

Comments
 (0)