Trevor Bossert f0a63e2712
Add basic call to scarf to get anonymous analytics (#1705)
There is a built in option to not send data by setting an env var,
SCARF_NO_ANALYTICS=true.

DoD:
- When importing or running unstructured package it will make a get call
to scarf
- When env variable is set to not track, call is not made
2023-10-11 09:15:36 -07:00

25 lines
686 B
Python

import logging
from unstructured.utils import scarf_analytics
logger = logging.getLogger("unstructured")
trace_logger = logging.getLogger("unstructured.trace")
# Create a custom logging level
DETAIL = 15
logging.addLevelName(DETAIL, "DETAIL")
# Create a custom log method for the "DETAIL" level
def detail(self, message, *args, **kws):
if self.isEnabledFor(DETAIL):
self._log(DETAIL, message, args, **kws)
# Note(Trevor,Crag): to opt out of scarf analytics, set the environment variable:
# SCARF_NO_ANALYTICS=true. See the README for more info.
scarf_analytics()
# Add the custom log method to the logging.Logger class
logging.Logger.detail = detail # type: ignore