Skip to main content

A logging package that integrates with Sentry for Newonder projects

Project description

Newonder Sentry Log

A logging package that integrates with Sentry for Newonder projects.

Installation

pip install newonder-sentry-log

Usage

Basic Usage

from newonder_sentry_log import NewonderLog

# Initialize the logger
logger = NewonderLog(
    project_name="YourProjectName",
    project_version="1.0.1",
    author="your_name",
    sentry_url="your_sentry_dsn_url",  # Sentry URL now required for Sentry integration
    email_domain="your-domain.com",  # Optional: custom email domain
    file_name="app_log",
    err_name="app_error"
)

# Use the logger
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.exception("This is an exception message")

Advanced Usage with Custom Parameters

from newonder_sentry_log import NewonderLog
import logging

# Initialize the logger with custom settings
logger = NewonderLog(
    project_name="AdvancedProject",
    project_version="2.0.0",
    author="advanced_user",
    set_level="work",  # or "debug" for development
    sentry_url="your_custom_sentry_dsn_url",
    email_domain="your-company.com",  # Custom email domain
    file_name="custom_app_log",
    err_name="custom_app_error",
    log_level=logging.DEBUG,
    error_log_level=logging.ERROR
)

# Use with extra parameters
logger.info("Processing data", farm="FarmA", turbine="Turbine1", func_name="data_processor")

# Add custom extra data
extra_data = {
    "custom_field": "custom_value",
    "processing_time": 125
}
logger.info("Data processed", farm="FarmB", turbine="Turbine2", extra=extra_data)

Customization Options

You can customize various aspects of the logger:

Parameter Description Default Value
project_name Name of your project Required
project_version Version of your project Required
author Author of the project Required
set_level Log level ('work' for production, other values for development) 'work'
sentry_url Custom Sentry DSN URL (required for Sentry integration) None
email_domain Email domain for user identification 'xinhuadu.com.cn'
file_name Name of the info log file None
err_name Name of the error log file None
log_level Minimum level for info logs logging.INFO
error_log_level Minimum level for error logs logging.ERROR

Publishing the Package

To publish this package to PyPI:

  1. Install build tools:

    pip install setuptools wheel twine
    
  2. Build the package:

    python setup.py sdist bdist_wheel
    
  3. Upload to PyPI:

    twine upload dist/*
    

Development

To install the package in development mode:

pip install -e .

Requirements

  • Python >= 3.7
  • sentry-sdk >= 1.0.0

See requirements.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newonder_sentry_log-1.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newonder_sentry_log-1.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file newonder_sentry_log-1.0.1.tar.gz.

File metadata

  • Download URL: newonder_sentry_log-1.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for newonder_sentry_log-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c635fcce0d65f6ea4dd8fc2520725d9ee40cdb27bf9cf61369216cc3714512c1
MD5 c0cfe8b5be9b692b47c6874f0cf9fcdf
BLAKE2b-256 9490af2e6c84dc6930491208320917f6be68f7e0ec880281222756800568cba8

See more details on using hashes here.

File details

Details for the file newonder_sentry_log-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for newonder_sentry_log-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d17c56af824f96d90346c9053a77553361a1c1e33b55ebccf88b450043c1752b
MD5 6b0f2d60c15b9f1dc91873295c996b7c
BLAKE2b-256 ba8284f78a9296f09bf881d59d510935bcd1800fd9a97592352442ebe8220f16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page