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.2",
    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
    log_path="/path/to/your/logs",  # Optional: custom log path
    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
    log_path="/var/log/myapp",  # Custom log path
    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'
log_path Custom path for log files '../log' relative to module
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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

newonder_sentry_log-1.0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for newonder_sentry_log-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9b314c2e49700848585c0f1ea6db8c4ec2d0c1dd34d3b7723277b8237aba0c2e
MD5 5419479518cb445fb19abdc678572efb
BLAKE2b-256 1acc8ed80bce05523d60f42c9923564c01e23c24739b8f6a0bfc2787eac34a9d

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