https://github.com/henleykuang/remote-logger
Remote Logger is a Python library that simplifies cloud logging services such as Sentry and Stackdriver, and allows you to easily integrate them with Python's native logging.
https://github.com/henleykuang/remote-logger
cloud google logging python remote sentry stackdriver stackdriver-error-reporting stackdriver-logs stackdriver-monitoring
Last synced: 3 months ago
JSON representation
Remote Logger is a Python library that simplifies cloud logging services such as Sentry and Stackdriver, and allows you to easily integrate them with Python's native logging.
- Host: GitHub
- URL: https://github.com/henleykuang/remote-logger
- Owner: HenleyKuang
- License: gpl-3.0
- Created: 2019-08-13T23:01:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-21T22:31:58.000Z (almost 3 years ago)
- Last Synced: 2025-10-08T15:58:28.002Z (3 months ago)
- Topics: cloud, google, logging, python, remote, sentry, stackdriver, stackdriver-error-reporting, stackdriver-logs, stackdriver-monitoring
- Language: Python
- Homepage:
- Size: 76.2 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. image:: https://img.shields.io/badge/License-GPL%20v3-blue.svg
:target: https://www.gnu.org/licenses/gpl-3.0
.. image:: https://badge.fury.io/py/remote-logger.svg
:target: https://pypi.org/project/remote-logger/
.. image:: https://img.shields.io/travis/HenleyKuang/remote-logger.svg
:target: https://travis-ci.org/HenleyKuang/remote-logger
Remote Logger
=============
Installation
------------
.. code-block:: bash
pip install remote-logger
Examples
--------
Initializing RemoteLogger with Sentry
.. code-block:: python
import logging
from remote_logger.clients.sentry_logger_client import SentryLoggerClient
from remote_logger.remote_logger_handler import RemoteLoggerHandler
LOGGER = logging.getLogger(__name__)
dsn = "https://@sentry.io/"
sentry_client = SentryLoggerClient(dsn=dsn)
sentry_handler = RemoteLoggerHandler(client=sentry_client)
sentry_handler.setLevel(logging.ERROR)
LOGGER.addHandler(sentry_handler)
Initializing RemoteLogger with Stackdriver
.. code-block:: python
import logging
from remote_logger.clients.stackdriver_logger_client import StackdriverLoggerClient
from remote_logger.remote_logger_handler import RemoteLoggerHandler
LOGGER = logging.getLogger(__name__)
# With service key
service_key_path = "/path/to/key.json"
stackdriver_client = StackdriverLoggerClient(service_key_path=service_key_path)
# Without service key
stackdriver_client = StackdriverLoggerClient()
stackdriver_handler = RemoteLoggerHandler(stackdriver_client)
stackdriver_handler.setLevel(logging.ERROR)
LOGGER.addHandler(stackdriver_handler)
Sending events to RemoteLogger
.. code-block:: python
dummy_group_id = 99
primary_metadata = {
"pkey1": "pvalue1",
"pkey2": "pvalue2",
"pkey3": "pvalue3",
}
secondary_metadata = {
"skey1": "svalue1",
"skey2": "svalue2",
"skey3": "svalue3",
}
LOGGER.error("Test Message", extra={
"group_id": dummy_group_id,
"primary_metadata": primary_metadata,
"secondary_metadata": secondary_metadata,
})