mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-09 14:40:53 +00:00
Feat/issue 605 debug logging via env variable (#608)
* feat: Debug Logging via Environment Variable * refactor: deleted libp2p/utils.py * fix: double messages logging fix * doc: add logging info to getting_started.rst
This commit is contained in:
22
libp2p/utils/version.py
Normal file
22
libp2p/utils/version.py
Normal file
@ -0,0 +1,22 @@
|
||||
from importlib.metadata import (
|
||||
version,
|
||||
)
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("libp2p.utils.version")
|
||||
|
||||
|
||||
def get_agent_version() -> str:
|
||||
"""
|
||||
Return the version of libp2p.
|
||||
|
||||
If the version cannot be determined due to an exception, return "py-libp2p/unknown".
|
||||
|
||||
:return: The version of libp2p.
|
||||
:rtype: str
|
||||
"""
|
||||
try:
|
||||
return f"py-libp2p/{version('libp2p')}"
|
||||
except Exception as e:
|
||||
logger.warning("Could not fetch libp2p version: %s", e)
|
||||
return "py-libp2p/unknown"
|
||||
Reference in New Issue
Block a user