Skip to main content

A Python client for the telegram-logger service

Project description

🚀 telegram-logger-client: Your Log's New Best Friend

Welcome to the telegram-logger-client - where your logs go to become stars!

🛠 Prerequisites

Before you dive in, make sure you've got your backstage pass ready:

  1. You'll need to set up and run the telegram-logger service. It's like the bouncer at the club - without it, your logs aren't getting in.

  2. Head over to https://github.com/psyb0t/telegram-logger for the VIP instructions on setting up the telegram-logger service.

  3. Once you've got that service up and running, come back here and let's make some noise!

🎭 Installation (No Secret Handshake Required)

Install this badass as a module and executable:

pip install telegram-logger-client

Go with pipx to just use it as an executable:

pipx install telegram-logger-client

🕹️ Usage (AKA How to Make Some Noise)

🐍 As a Python Module

Summon the TelegramLoggerClient in your Python code:

from telegram_logger_client import TelegramLoggerClient

# Create your logger
logger = TelegramLoggerClient("https://your-logger-url.com", "your-secret-token")

# Send a log (it's like tweeting, but geekier)
logger.send_log(
    caller="CoffeeBot",
    level="warning",
    message="Coffee levels critically low!",
    error="Caffeine deficiency detected",
    request_id="coffee-run-42",
    trace_id="from-bed-to-coffee-machine",
    span_id="mug-to-mouth",
    data={"coffee_type": "Espresso", "sugar": False, "milk": "Oat"}
)

🖥️ Command Line Magic

First, set up your secret lair:

export TELEGRAM_LOGGER_BASE_URL=https://your-logger-url.com
export TELEGRAM_LOGGER_X_ID=your-secret-token

Now, shout into the void (or just send a log):

telegram-logger-client \
    --caller "WeatherBot" \
    --level "info" \
    --message "It's raining cats and dogs!" \
    --error "Umbrella malfunction" \
    --request-id "weather-101" \
    --trace-id "cloud-to-ground" \
    --span-id "drop-to-splash" \
    --data '{"temperature": "chilly", "wind": "breezy"}'

Want to see every little detail? Add the --debug flag:

telegram-logger-client \
    --debug \
    --caller "WeatherBot" \
    --level "info" \
    --message "It's raining cats and dogs!"

🎭 Logging Levels (Choose Your Adventure)

The client itself has two modes:

  • Normal Mode (default): "Just the highlights" mode
  • Debug Mode: "I can hear a pin drop" mode

Your logs, on the other hand, can be as dramatic as you want:

  • "info": "Just FYI" level
  • "warning": "Hmm, that's interesting" level
  • "error": "Houston, we have a problem" level

🧙‍♂️ API Reference (The Boring but Important Bit)

🔮 TelegramLoggerClient

__init__(base_url: str, x_id: str)

Create your logger. Feed it URLs and tokens.

send_log(...)

Send your log on a grand adventure. Pack its bags with:

  • caller: Who's making all this noise?
  • level: How important is this, really?
  • message: What's the scoop?
  • error: What went boom?
  • request_id: A unique ID for this particular escapade
  • trace_id: For retracing your steps
  • span_id: A slice of time in the grand timeline
  • data: Any extra bits and bobs

Returns a requests.Response object (a postcard from your log's journey).

🗝️ Environment Variables (Your Logger's Secret Code)

  • TELEGRAM_LOGGER_BASE_URL: Where your logs call home
  • TELEGRAM_LOGGER_X_ID: Your logger's super-secret identity

🎲 Command Line Arguments (For When You're Feeling Bossy)

  • --debug: Unleash the full power of logging (optional)
  • --base-url: A new home for your logs
  • --x-id: A new secret identity
  • --caller: Who's calling?
  • --level: On a scale of "meh" to "THE WORLD IS ENDING!"
  • --message: Your log's 15 minutes of fame
  • --error: What's gone sideways?
  • --request-id: This log's personal serial number
  • --trace-id: Breadcrumbs in the digital forest
  • --span-id: A moment in time
  • --data: Everything else but the kitchen sink

Remember: Command line arguments are the divas of the coding world - they always steal the show from environment variables.

📜 License (The Fine Print)

This project is unleashed under the WTFPL License – Do What The F**k You Want To Public License. Your imagination is the only limit, push it to the boundaries!

Now go forth and log like there's no tomorrow! May your errors be few and your insights be plentiful. Happy logging! 📝🚀

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

telegram_logger_client-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

telegram_logger_client-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file telegram_logger_client-0.1.0.tar.gz.

File metadata

File hashes

Hashes for telegram_logger_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c9e740e400bcb3a4de88748d96ea3f646a9ade10d892b05fb6b0a120ffbb19e
MD5 881e627a2d2bf7b5e35737ff3c94b92d
BLAKE2b-256 d2f503de3607fb07d486d8de7c61f35dcae929db7be6d1dd2a732aa51ad8c0ed

See more details on using hashes here.

File details

Details for the file telegram_logger_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_logger_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 197e387baefd0d9abeeed08c226ea692cf756f07fca2ba95ca5cab6e7776f58a
MD5 e54f459167693d583b20e663013d1733
BLAKE2b-256 0fbc0adeffa16925595bd1a95e1f9277ad14c6cb1f60c6e884ddadb502b52d48

See more details on using hashes here.

Supported by

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