Third Eye's Python logging SDK for enriched application logs with optional direct storage in your own database
Project description
Third Eye Python Logging SDK
Third Eye's Python logging SDK enriches standard Python logs with application and source context, with optional direct storage in your own database.
It supports familiar logging methods such as debug, info, warning, error,
exception, and critical, while automatically capturing useful metadata including:
- Service, environment, and application version
- Git commit SHA
- Source file, function, and line number
- Trace, span, request, and user identifiers
- Message templates and custom attributes
- Optional stack information
When THIRDEYE_DATABASE_URL is configured, the SDK writes enriched logs directly
to your database. Without it, logs only use Python's local logging module.
Installation
pip install thirdeye-logging
The distribution name is thirdeye-logging; the Python import remains thirdeye.
The base installation supports local logging without installing database drivers.
Usage
Use Third Eye like Python's standard logging library:
import thirdeye
logger = thirdeye.getLogger(__name__)
logger.info(
"Order %s processed",
"ord_123",
trace_id="trace_123",
user_id="user_456",
)
trace_id, span_id, request_id, and user_id are not stored by the default
database schema. Add their column names to THIRDEYE_DATABASE_COLUMNS when you
want to persist them. Other custom attributes are only stored when attributes is
selected.
Third Eye configures basic console logging at INFO when the application has not
already configured Python logging. To use a custom format, configure logging before
importing Third Eye; the existing configuration takes precedence:
import logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s %(message)s",
)
import thirdeye
If you configure logging after importing Third Eye, pass force=True to
logging.basicConfig(...) so Python replaces the existing basic configuration.
Use thirdeye.set_log_level(...) to change the level for existing and future Third
Eye loggers, for example thirdeye.set_log_level(thirdeye.LogLevel.DEBUG).
Loggers returned by getLogger send events through one shared uploader. Importing
Third Eye does not connect to or modify the database. The uploader initializes the
database and creates or updates the table when the first application log is sent.
Database setup
Third Eye supports PostgreSQL, MySQL, SQLite, and Microsoft SQL Server.
Install the extra for the database you use:
| Database | Installation |
|---|---|
| PostgreSQL | pip install "thirdeye-logging[postgresql]" |
| MySQL | pip install "thirdeye-logging[mysql]" |
| SQLite | pip install "thirdeye-logging[sqlite]" |
| Microsoft SQL Server | pip install "thirdeye-logging[mssql]" |
If the selected database dependency is missing, Third Eye logs a local warning and continues running without uploading that event.
Set the database URL before importing the library:
export THIRDEYE_DATABASE_URL="postgresql://user:password@localhost/database"
You may optionally configure the destination table and stored columns:
export THIRDEYE_DATABASE_TABLE="thirdeye_logs"
export THIRDEYE_DATABASE_COLUMNS="timestamp,level,message,service,environment,trace_id,user_id,attributes"
Table configuration
Third Eye creates the table on the first upload if it does not exist. The default table
is thirdeye_logs, and its default columns are timestamp, level, service, and
message. Identifiers and custom attributes supplied to a log event are only
persisted when their columns are selected.
Set THIRDEYE_DATABASE_COLUMNS to a comma-separated list to select different
columns. When the table already exists, Third Eye adds any selected columns that are
missing. It does not change or remove existing columns. All selected columns are
nullable.
Available columns:
| Column | Description | Default |
|---|---|---|
timestamp |
UTC time when the log event was created. | ✓ |
level |
Log level such as INFO, WARNING, or ERROR. |
✓ |
message |
Formatted log message. | ✓ |
args |
JSON array of arguments passed to the message template. | |
template |
Original unformatted message template. | |
service |
Service name discovered from environment or project metadata. | ✓ |
environment |
Application environment such as production or staging. | |
version |
Service or application version. | |
git_sha |
Git commit SHA. | |
trace_id |
Trace identifier supplied with the log event. | |
span_id |
Span identifier supplied with the log event. | |
request_id |
Request identifier supplied with the log event. | |
user_id |
User identifier supplied with the log event. | |
file |
Source file that emitted the log. | |
line |
Source line number. | |
function |
Function that emitted the log. | |
stack |
Exception traceback or stack information requested with stack_info. |
|
attributes |
JSON object containing other keyword attributes. |
Use JSON-capable columns for args and attributes when providing an existing
table.
Privacy
Third Eye does not send logs or credentials to Third Eye Tech. Without
THIRDEYE_DATABASE_URL, logs remain local. When a database URL is configured, the
SDK writes directly to that database.
Log messages can contain sensitive information. Avoid logging credentials or personal data, use pseudonymous identifiers, and select optional metadata columns only when needed. Source paths, stack traces, request and user identifiers, message arguments, and custom attributes are not stored by default.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thirdeye_logging-0.1.0.tar.gz.
File metadata
- Download URL: thirdeye_logging-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51ab7f1c51fd09dfc308c4ae18be383af311597f214aaba0b48946ad0293e9ba
|
|
| MD5 |
0cfa0d531dfd5d54420bbe89368cd5f7
|
|
| BLAKE2b-256 |
6a76758eac9b500f6d32c4be5c392b02b20c23838f3dc2cd04a854f90fee5d21
|
Provenance
The following attestation bundles were made for thirdeye_logging-0.1.0.tar.gz:
Publisher:
release.yml on 3rd-eye-tech/logging-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thirdeye_logging-0.1.0.tar.gz -
Subject digest:
51ab7f1c51fd09dfc308c4ae18be383af311597f214aaba0b48946ad0293e9ba - Sigstore transparency entry: 2214951897
- Sigstore integration time:
-
Permalink:
3rd-eye-tech/logging-python@1b8e8f64299dc6d25abb9579540c3a6c8e139d96 -
Branch / Tag:
refs/tags/release-0.1.0 - Owner: https://github.com/3rd-eye-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b8e8f64299dc6d25abb9579540c3a6c8e139d96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thirdeye_logging-0.1.0-py3-none-any.whl.
File metadata
- Download URL: thirdeye_logging-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ed9ad49654541fa1b580d38ad265d80f8fc96fb3818d7f39d33da93263b6b27
|
|
| MD5 |
60d362a3359e52f1b849899228f44827
|
|
| BLAKE2b-256 |
1b647dd53851ba891137c39e45764d1d3f305aefb39d12e4259c5269c0ba0c0b
|
Provenance
The following attestation bundles were made for thirdeye_logging-0.1.0-py3-none-any.whl:
Publisher:
release.yml on 3rd-eye-tech/logging-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thirdeye_logging-0.1.0-py3-none-any.whl -
Subject digest:
2ed9ad49654541fa1b580d38ad265d80f8fc96fb3818d7f39d33da93263b6b27 - Sigstore transparency entry: 2214951927
- Sigstore integration time:
-
Permalink:
3rd-eye-tech/logging-python@1b8e8f64299dc6d25abb9579540c3a6c8e139d96 -
Branch / Tag:
refs/tags/release-0.1.0 - Owner: https://github.com/3rd-eye-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b8e8f64299dc6d25abb9579540c3a6c8e139d96 -
Trigger Event:
release
-
Statement type: