✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ server366.web-hosting.com ​🇻​♯➤ 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 67.223.118.204 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.217.62
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations//logging.py
import logging
import sys
from datetime import datetime, timezone
from fnmatch import fnmatch
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk.client import BaseClient
from sentry_sdk.integrations import Integration
from sentry_sdk.logger import _log_level_to_otel
from sentry_sdk.utils import (
    capture_internal_exceptions,
    current_stacktrace,
    event_from_exception,
    has_logs_enabled,
    safe_repr,
    to_string,
)

if TYPE_CHECKING:
    from collections.abc import MutableMapping
    from logging import LogRecord
    from typing import Any, Dict, Optional

DEFAULT_LEVEL = logging.INFO
DEFAULT_EVENT_LEVEL = logging.ERROR
LOGGING_TO_EVENT_LEVEL = {
    logging.NOTSET: "notset",
    logging.DEBUG: "debug",
    logging.INFO: "info",
    logging.WARN: "warning",  # WARN is same a WARNING
    logging.WARNING: "warning",
    logging.ERROR: "error",
    logging.FATAL: "fatal",
    logging.CRITICAL: "fatal",  # CRITICAL is same as FATAL
}

# Map logging level numbers to corresponding OTel level numbers
SEVERITY_TO_OTEL_SEVERITY = {
    logging.CRITICAL: 21,  # fatal
    logging.ERROR: 17,  # error
    logging.WARNING: 13,  # warn
    logging.INFO: 9,  # info
    logging.DEBUG: 5,  # debug
}


# Capturing events from those loggers causes recursion errors. We cannot allow
# the user to unconditionally create events from those loggers under any
# circumstances.
#
# Note: Ignoring by logger name here is better than mucking with thread-locals.
# We do not necessarily know whether thread-locals work 100% correctly in the user's environment.
#
# Events/breadcrumbs and Sentry Logs have separate ignore lists so that
# framework loggers silenced for events (e.g. django.server) can still be
# captured as Sentry Logs.
_IGNORED_LOGGERS = set(
    ["sentry_sdk.errors", "urllib3.connectionpool", "urllib3.connection"]
)

_IGNORED_LOGGERS_SENTRY_LOGS = set(
    ["sentry_sdk.errors", "urllib3.connectionpool", "urllib3.connection"]
)


def ignore_logger(
    name: str,
) -> None:
    """This disables recording (both in breadcrumbs and as events) calls to
    a logger of a specific name.  Among other uses, many of our integrations
    use this to prevent their actions being recorded as breadcrumbs. Exposed
    to users as a way to quiet spammy loggers.

    This does **not** affect Sentry Logs — use
    :py:func:`ignore_logger_for_sentry_logs` for that.

    :param name: The name of the logger to ignore (same string you would pass to ``logging.getLogger``).
    """
    _IGNORED_LOGGERS.add(name)


def ignore_logger_for_sentry_logs(
    name: str,
) -> None:
    """This disables recording as Sentry Logs calls to a logger of a
    specific name.

    :param name: The name of the logger to ignore (same string you would pass to ``logging.getLogger``).
    """
    _IGNORED_LOGGERS_SENTRY_LOGS.add(name)


def unignore_logger(
    name: str,
) -> None:
    """Reverts a previous :py:func:`ignore_logger` call, re-enabling
    recording of breadcrumbs and events for the named logger.

    :param name: The name of the logger to unignore.
    """
    _IGNORED_LOGGERS.discard(name)


def unignore_logger_for_sentry_logs(
    name: str,
) -> None:
    """Reverts a previous :py:func:`ignore_logger_for_sentry_logs` call,
    re-enabling recording of Sentry Logs for the named logger.

    :param name: The name of the logger to unignore.
    """
    _IGNORED_LOGGERS_SENTRY_LOGS.discard(name)


class LoggingIntegration(Integration):
    identifier = "logging"

    def __init__(
        self,
        level: "Optional[int]" = DEFAULT_LEVEL,
        event_level: "Optional[int]" = DEFAULT_EVENT_LEVEL,
        sentry_logs_level: "Optional[int]" = DEFAULT_LEVEL,
    ) -> None:
        self._handler = None
        self._breadcrumb_handler = None
        self._sentry_logs_handler = None

        if level is not None:
            self._breadcrumb_handler = BreadcrumbHandler(level=level)

        if sentry_logs_level is not None:
            self._sentry_logs_handler = SentryLogsHandler(level=sentry_logs_level)

        if event_level is not None:
            self._handler = EventHandler(level=event_level)

    def _handle_record(self, record: "LogRecord") -> None:
        if self._handler is not None and record.levelno >= self._handler.level:
            self._handler.handle(record)

        if (
            self._breadcrumb_handler is not None
            and record.levelno >= self._breadcrumb_handler.level
        ):
            self._breadcrumb_handler.handle(record)

    def _handle_sentry_logs_record(self, record: "LogRecord") -> None:
        if (
            self._sentry_logs_handler is not None
            and record.levelno >= self._sentry_logs_handler.level
        ):
            self._sentry_logs_handler.handle(record)

    @staticmethod
    def setup_once() -> None:
        old_callhandlers = logging.Logger.callHandlers

        def sentry_patched_callhandlers(self: "Any", record: "LogRecord") -> "Any":
            # keeping a local reference because the
            # global might be discarded on shutdown
            ignored_loggers = _IGNORED_LOGGERS
            ignored_loggers_sentry_logs = _IGNORED_LOGGERS_SENTRY_LOGS

            try:
                return old_callhandlers(self, record)
            finally:
                # This check is done twice, once also here before we even get
                # the integration.  Otherwise we have a high chance of getting
                # into a recursion error when the integration is resolved
                # (this also is slower).
                name = record.name.strip()

                handle_events = (
                    ignored_loggers is not None and name not in ignored_loggers
                )
                handle_sentry_logs = (
                    ignored_loggers_sentry_logs is not None
                    and name not in ignored_loggers_sentry_logs
                )

                if handle_events or handle_sentry_logs:
                    integration = sentry_sdk.get_client().get_integration(
                        LoggingIntegration
                    )
                    if integration is not None:
                        if handle_events:
                            integration._handle_record(record)
                        if handle_sentry_logs:
                            integration._handle_sentry_logs_record(record)

        logging.Logger.callHandlers = sentry_patched_callhandlers  # type: ignore


class _BaseHandler(logging.Handler):
    COMMON_RECORD_ATTRS = frozenset(
        (
            "args",
            "created",
            "exc_info",
            "exc_text",
            "filename",
            "funcName",
            "levelname",
            "levelno",
            "linenno",
            "lineno",
            "message",
            "module",
            "msecs",
            "msg",
            "name",
            "pathname",
            "process",
            "processName",
            "relativeCreated",
            "stack",
            "tags",
            "taskName",
            "thread",
            "threadName",
            "stack_info",
        )
    )

    def _logging_to_event_level(self, record: "LogRecord") -> str:
        return LOGGING_TO_EVENT_LEVEL.get(
            record.levelno, record.levelname.lower() if record.levelname else ""
        )

    def _extra_from_record(self, record: "LogRecord") -> "MutableMapping[str, object]":
        return {
            k: v
            for k, v in vars(record).items()
            if k not in self.COMMON_RECORD_ATTRS
            and (not isinstance(k, str) or not k.startswith("_"))
        }


class EventHandler(_BaseHandler):
    """
    A logging handler that emits Sentry events for each log record

    Note that you do not have to use this class if the logging integration is enabled, which it is by default.
    """

    def _can_record(self, record: "LogRecord") -> bool:
        """Prevents ignored loggers from recording"""
        for logger in _IGNORED_LOGGERS:
            if fnmatch(record.name.strip(), logger):
                return False
        return True

    def emit(self, record: "LogRecord") -> "Any":
        with capture_internal_exceptions():
            self.format(record)
            return self._emit(record)

    def _emit(self, record: "LogRecord") -> None:
        if not self._can_record(record):
            return

        client = sentry_sdk.get_client()
        if not client.is_active():
            return

        client_options = client.options

        # exc_info might be None or (None, None, None)
        #
        # exc_info may also be any falsy value due to Python stdlib being
        # liberal with what it receives and Celery's billiard being "liberal"
        # with what it sends. See
        # https://github.com/getsentry/sentry-python/issues/904
        if record.exc_info and record.exc_info[0] is not None:
            event, hint = event_from_exception(
                record.exc_info,
                client_options=client_options,
                mechanism={"type": "logging", "handled": True},
            )
        elif (record.exc_info and record.exc_info[0] is None) or record.stack_info:
            event = {}
            hint = {}
            with capture_internal_exceptions():
                event["threads"] = {
                    "values": [
                        {
                            "stacktrace": current_stacktrace(
                                include_local_variables=client_options[
                                    "include_local_variables"
                                ],
                                max_value_length=client_options["max_value_length"],
                            ),
                            "crashed": False,
                            "current": True,
                        }
                    ]
                }
        else:
            event = {}
            hint = {}

        hint["log_record"] = record

        level = self._logging_to_event_level(record)
        if level in {"debug", "info", "warning", "error", "critical", "fatal"}:
            event["level"] = level  # type: ignore[typeddict-item]
        event["logger"] = record.name

        if (
            sys.version_info < (3, 11)
            and record.name == "py.warnings"
            and record.msg == "%s"
        ):
            # warnings module on Python 3.10 and below sets record.msg to "%s"
            # and record.args[0] to the actual warning message.
            # This was fixed in https://github.com/python/cpython/pull/30975.
            message = record.args[0]
            params = ()
        else:
            message = record.msg
            params = record.args

        event["logentry"] = {
            "message": to_string(message),
            "formatted": record.getMessage(),
            "params": params,
        }

        event["extra"] = self._extra_from_record(record)

        sentry_sdk.capture_event(event, hint=hint)


# Legacy name
SentryHandler = EventHandler


class BreadcrumbHandler(_BaseHandler):
    """
    A logging handler that records breadcrumbs for each log record.

    Note that you do not have to use this class if the logging integration is enabled, which it is by default.
    """

    def _can_record(self, record: "LogRecord") -> bool:
        """Prevents ignored loggers from recording"""
        for logger in _IGNORED_LOGGERS:
            if fnmatch(record.name.strip(), logger):
                return False
        return True

    def emit(self, record: "LogRecord") -> "Any":
        with capture_internal_exceptions():
            self.format(record)
            return self._emit(record)

    def _emit(self, record: "LogRecord") -> None:
        if not self._can_record(record):
            return

        sentry_sdk.add_breadcrumb(
            self._breadcrumb_from_record(record), hint={"log_record": record}
        )

    def _breadcrumb_from_record(self, record: "LogRecord") -> "Dict[str, Any]":
        return {
            "type": "log",
            "level": self._logging_to_event_level(record),
            "category": record.name,
            "message": record.message,
            "timestamp": datetime.fromtimestamp(record.created, timezone.utc),
            "data": self._extra_from_record(record),
        }


class SentryLogsHandler(_BaseHandler):
    """
    A logging handler that records Sentry logs for each Python log record.

    Note that you do not have to use this class if the logging integration is enabled, which it is by default.
    """

    def _can_record(self, record: "LogRecord") -> bool:
        """Prevents ignored loggers from recording"""
        for logger in _IGNORED_LOGGERS_SENTRY_LOGS:
            if fnmatch(record.name.strip(), logger):
                return False
        return True

    def emit(self, record: "LogRecord") -> "Any":
        with capture_internal_exceptions():
            self.format(record)
            if not self._can_record(record):
                return

            client = sentry_sdk.get_client()
            if not client.is_active():
                return

            if not has_logs_enabled(client.options):
                return

            self._capture_log_from_record(client, record)

    def _capture_log_from_record(
        self, client: "BaseClient", record: "LogRecord"
    ) -> None:
        otel_severity_number, otel_severity_text = _log_level_to_otel(
            record.levelno, SEVERITY_TO_OTEL_SEVERITY
        )
        project_root = client.options["project_root"]

        attrs: "Any" = self._extra_from_record(record)
        attrs["sentry.origin"] = "auto.log.stdlib"

        parameters_set = False
        if record.args is not None:
            if isinstance(record.args, tuple):
                parameters_set = bool(record.args)
                for i, arg in enumerate(record.args):
                    attrs[f"sentry.message.parameter.{i}"] = (
                        arg
                        if isinstance(arg, (str, float, int, bool))
                        else safe_repr(arg)
                    )
            elif isinstance(record.args, dict):
                parameters_set = bool(record.args)
                for key, value in record.args.items():
                    attrs[f"sentry.message.parameter.{key}"] = (
                        value
                        if isinstance(value, (str, float, int, bool))
                        else safe_repr(value)
                    )

        if parameters_set and isinstance(record.msg, str):
            # only include template if there is at least one
            # sentry.message.parameter.X set
            attrs["sentry.message.template"] = record.msg

        if record.lineno:
            attrs["code.line.number"] = record.lineno

        if record.pathname:
            if project_root is not None and record.pathname.startswith(project_root):
                attrs["code.file.path"] = record.pathname[len(project_root) + 1 :]
            else:
                attrs["code.file.path"] = record.pathname

        if record.funcName:
            attrs["code.function.name"] = record.funcName

        if record.thread:
            attrs["thread.id"] = record.thread
        if record.threadName:
            attrs["thread.name"] = record.threadName

        if record.process:
            attrs["process.pid"] = record.process
        if record.processName:
            attrs["process.executable.name"] = record.processName
        if record.name:
            attrs["logger.name"] = record.name

        # noinspection PyProtectedMember
        sentry_sdk.get_current_scope()._capture_log(
            {
                "severity_text": otel_severity_text,
                "severity_number": otel_severity_number,
                "body": record.message,
                "attributes": attrs,
                "time_unix_nano": int(record.created * 1e9),
                "trace_id": None,
                "span_id": None,
            },
        )


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
11 Jun 2026 5.00 AM
root / root
0755
__pycache__
--
11 Jun 2026 5.00 AM
root / root
0755
celery
--
11 Jun 2026 5.00 AM
root / root
0755
django
--
11 Jun 2026 5.00 AM
root / root
0755
google_genai
--
11 Jun 2026 5.00 AM
root / root
0755
grpc
--
11 Jun 2026 5.00 AM
root / root
0755
openai_agents
--
11 Jun 2026 5.00 AM
root / root
0755
opentelemetry
--
11 Jun 2026 5.00 AM
root / root
0755
pydantic_ai
--
11 Jun 2026 5.00 AM
root / root
0755
redis
--
11 Jun 2026 5.00 AM
root / root
0755
spark
--
11 Jun 2026 5.00 AM
root / root
0755
__init__.py
12.511 KB
11 Jun 2026 5.00 AM
root / root
0644
_asgi_common.py
4.003 KB
11 Jun 2026 5.00 AM
root / root
0644
_wsgi_common.py
7.281 KB
11 Jun 2026 5.00 AM
root / root
0644
aiohttp.py
19.277 KB
11 Jun 2026 5.00 AM
root / root
0644
aiomysql.py
9.09 KB
11 Jun 2026 5.00 AM
root / root
0644
anthropic.py
39 KB
11 Jun 2026 5.00 AM
root / root
0644
argv.py
0.855 KB
11 Jun 2026 5.00 AM
root / root
0644
ariadne.py
5.698 KB
11 Jun 2026 5.00 AM
root / root
0644
arq.py
9.229 KB
11 Jun 2026 5.00 AM
root / root
0644
asgi.py
20.061 KB
11 Jun 2026 5.00 AM
root / root
0644
asyncio.py
9.275 KB
11 Jun 2026 5.00 AM
root / root
0644
asyncpg.py
9.68 KB
11 Jun 2026 5.00 AM
root / root
0644
atexit.py
1.509 KB
11 Jun 2026 5.00 AM
root / root
0644
aws_lambda.py
17.41 KB
11 Jun 2026 5.00 AM
root / root
0644
beam.py
4.907 KB
11 Jun 2026 5.00 AM
root / root
0644
boto3.py
6.198 KB
11 Jun 2026 5.00 AM
root / root
0644
bottle.py
7.208 KB
11 Jun 2026 5.00 AM
root / root
0644
chalice.py
4.506 KB
11 Jun 2026 5.00 AM
root / root
0644
clickhouse_driver.py
5.846 KB
11 Jun 2026 5.00 AM
root / root
0644
cloud_resource_context.py
7.488 KB
11 Jun 2026 5.00 AM
root / root
0644
cohere.py
10.44 KB
11 Jun 2026 5.00 AM
root / root
0644
dedupe.py
1.857 KB
11 Jun 2026 5.00 AM
root / root
0644
dramatiq.py
8.016 KB
11 Jun 2026 5.00 AM
root / root
0644
excepthook.py
2.249 KB
11 Jun 2026 5.00 AM
root / root
0644
executing.py
1.935 KB
11 Jun 2026 5.00 AM
root / root
0644
falcon.py
9.04 KB
11 Jun 2026 5.00 AM
root / root
0644
fastapi.py
5.281 KB
11 Jun 2026 5.00 AM
root / root
0644
flask.py
8.274 KB
11 Jun 2026 5.00 AM
root / root
0644
gcp.py
10.57 KB
11 Jun 2026 5.00 AM
root / root
0644
gnu_backtrace.py
2.724 KB
11 Jun 2026 5.00 AM
root / root
0644
gql.py
4.927 KB
11 Jun 2026 5.00 AM
root / root
0644
graphene.py
5.707 KB
11 Jun 2026 5.00 AM
root / root
0644
httpx.py
9.788 KB
11 Jun 2026 5.00 AM
root / root
0644
httpx2.py
9.804 KB
11 Jun 2026 5.00 AM
root / root
0644
huey.py
8.189 KB
11 Jun 2026 5.00 AM
root / root
0644
huggingface_hub.py
15.282 KB
11 Jun 2026 5.00 AM
root / root
0644
langchain.py
48.313 KB
11 Jun 2026 5.00 AM
root / root
0644
langgraph.py
18.125 KB
11 Jun 2026 5.00 AM
root / root
0644
launchdarkly.py
1.873 KB
11 Jun 2026 5.00 AM
root / root
0644
litellm.py
13.033 KB
11 Jun 2026 5.00 AM
root / root
0644
litestar.py
11.464 KB
11 Jun 2026 5.00 AM
root / root
0644
logging.py
15.692 KB
11 Jun 2026 5.00 AM
root / root
0644
loguru.py
6.352 KB
11 Jun 2026 5.00 AM
root / root
0644
mcp.py
23.121 KB
11 Jun 2026 5.00 AM
root / root
0644
modules.py
0.769 KB
11 Jun 2026 5.00 AM
root / root
0644
openai.py
53.385 KB
11 Jun 2026 5.00 AM
root / root
0644
openfeature.py
1.076 KB
11 Jun 2026 5.00 AM
root / root
0644
otlp.py
7.99 KB
11 Jun 2026 5.00 AM
root / root
0644
pure_eval.py
4.413 KB
11 Jun 2026 5.00 AM
root / root
0644
pymongo.py
8.212 KB
11 Jun 2026 5.00 AM
root / root
0644
pyramid.py
7.416 KB
11 Jun 2026 5.00 AM
root / root
0644
pyreqwest.py
6.824 KB
11 Jun 2026 5.00 AM
root / root
0644
quart.py
7.318 KB
11 Jun 2026 5.00 AM
root / root
0644
ray.py
5.747 KB
11 Jun 2026 5.00 AM
root / root
0644
rq.py
7.807 KB
11 Jun 2026 5.00 AM
root / root
0644
rust_tracing.py
9.436 KB
11 Jun 2026 5.00 AM
root / root
0644
sanic.py
15.252 KB
11 Jun 2026 5.00 AM
root / root
0644
serverless.py
1.583 KB
11 Jun 2026 5.00 AM
root / root
0644
socket.py
5.018 KB
11 Jun 2026 5.00 AM
root / root
0644
sqlalchemy.py
5.242 KB
11 Jun 2026 5.00 AM
root / root
0644
starlette.py
27.935 KB
11 Jun 2026 5.00 AM
root / root
0644
starlite.py
11.037 KB
11 Jun 2026 5.00 AM
root / root
0644
statsig.py
1.186 KB
11 Jun 2026 5.00 AM
root / root
0644
stdlib.py
14.007 KB
11 Jun 2026 5.00 AM
root / root
0644
strawberry.py
17.391 KB
11 Jun 2026 5.00 AM
root / root
0644
sys_exit.py
2.352 KB
11 Jun 2026 5.00 AM
root / root
0644
threading.py
6.875 KB
11 Jun 2026 5.00 AM
root / root
0644
tornado.py
10.789 KB
11 Jun 2026 5.00 AM
root / root
0644
trytond.py
1.675 KB
11 Jun 2026 5.00 AM
root / root
0644
typer.py
1.725 KB
11 Jun 2026 5.00 AM
root / root
0644
unleash.py
1.021 KB
11 Jun 2026 5.00 AM
root / root
0644
unraisablehook.py
1.654 KB
11 Jun 2026 5.00 AM
root / root
0644
wsgi.py
15.031 KB
11 Jun 2026 5.00 AM
root / root
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF