### Full Gunicorn configuration example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/gunicorn.md A comprehensive example showing both LoglyWorker and manual setup options in gunicorn.conf.py. ```python # gunicorn.conf.py from logly.integrations.gunicorn import LoglyWorker, setup_gunicorn_logging # Option 1: Use LoglyWorker worker_class = "logly.integrations.gunicorn.LoglyWorker" bind = "0.0.0.0:8000" workers = 4 # Option 2: Manual setup (if using default worker) # setup_gunicorn_logging(level="INFO") # bind = "0.0.0.0:8000" # workers = 4 ``` -------------------------------- ### Logly Quick Start Example Source: https://github.com/muhammad-fiaz/logly/blob/main/README.md Demonstrates basic logging with various levels and completing the logger. ```python from logly import logger logger.trace("Detailed trace") logger.debug("Debug info") logger.info("Application started") logger.notice("Notice message") logger.success("Operation completed!") logger.warning("Warning message") logger.error("Error occurred") logger.fail("Operation failed") logger.critical("Critical system error!") logger.fatal("Fatal system failure!") logger.complete() ``` -------------------------------- ### Full FastAPI Example with Logly Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/fastapi.md Demonstrates a complete FastAPI application setup including LoglyMiddleware and example routes with logging. ```python from fastapi import FastAPI from logly import logger from logly.integrations.fastapi import LoglyMiddleware app = FastAPI() app.add_middleware(LoglyMiddleware) @app.get("/") async def root(): logger.info("Handling request") return {"message": "Hello World"} @app.get("/items/{item_id}") async def read_item(item_id: int): logger.debug("Fetching item {}", item_id) return {"item_id": item_id} ``` -------------------------------- ### Full Celery Integration Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/celery.md A comprehensive example demonstrating Celery setup with Logly, including patching task loggers for both the main app and individual tasks. This example configures a Redis broker. ```python from celery import Celery from logly.integrations.celery import setup_celery_logging, patch_task_logger app = Celery("myapp") app.conf.broker_url = "redis://localhost:6379/0" app.conf.on_after_configure.connect(setup_celery_logging) @app.task(bind=True) def process_order(self, order_id): logger = self.get_logger() patch_task_logger(logger) logger.info("Processing order %s", order_id) # ... process order logger.info("Order %s completed", order_id) @app.task def send_email(recipient, subject, body): logger = send_email.get_logger() patch_task_logger(logger) logger.info("Sending email to %s", recipient) # ... send email ``` -------------------------------- ### Full SQLAlchemy Logging Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/sqlalchemy.md A complete example demonstrating Logly's SQLAlchemy integration, including setup, model definition, engine creation, and session commit. ```python from sqlalchemy import create_engine, Column, Integer, String from sqlalchemy.orm import declarative_base, Session from logly.integrations.sqlalchemy import setup_sqlalchemy_logging setup_sqlalchemy_logging(level="INFO", echo=True) Base = declarative_base() class User(Base): __tablename__ = "users" id = Column(Integer, primary_key=True) name = Column(String(50)) engine = create_engine("sqlite:///db.sqlite3") Base.metadata.create_all(engine) with Session(engine) as session: user = User(name="Alice") session.add(user) session.commit() ``` -------------------------------- ### Quick Example of Logly Usage Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/index.md Demonstrates adding sinks with various configurations, logging messages at different levels, binding context to log records, and using the exception catching context manager. Ensure Logly is installed before use. ```python from logly import logger # Add sinks with per-sink configuration logger.add("app.log", level="DEBUG", rotation="daily", retention="30 days", compression="gzip") logger.add("errors.log", level="ERROR", rotation="daily", retention="90 days") logger.add("stdout", level="INFO", colorize=True) # Log at all levels logger.trace("Detailed trace") logger.debug("Debug info") logger.info("Application started") logger.notice("Notice message") logger.success("Operation completed!") logger.warning("Warning message") logger.error("Error occurred") logger.fail("Operation failed") logger.critical("Critical system error!") logger.fatal("Fatal system failure!") # Bind context app_logger = logger.bind(user_id="12345", request_id="abc-789") app_logger.info("User logged in") # Exception handling with logger.catch(): risky_operation() logger.complete() ``` -------------------------------- ### Full Example: APScheduler with Logly Integration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/apscheduler.md Demonstrates setting up APScheduler logging with Logly and scheduling a job. Ensure APScheduler is installed with logly extras. ```python from apscheduler.schedulers.background import BackgroundScheduler from logly import logger from logly.integrations.apscheduler import setup_apscheduler_logging setup_apscheduler_logging(level="INFO") scheduler = BackgroundScheduler() @scheduler.scheduled_job("interval", hours=1) def cleanup(): logger.info("Running cleanup job") scheduler.start() ``` -------------------------------- ### Production Environment Setup with Explicit Configuration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/environment-variables.md In production, it's recommended to disable auto-initialization and explicitly configure sinks. This example sets LOGLY_AUTOINIT to false and adds specific log files with rotation and compression. ```python import os os.environ["LOGLY_AUTOINIT"] = "false" from logly import logger logger.add("logs/app.log", level="INFO", rotation="daily", compression="gzip") logger.add("logs/errors.log", level="ERROR") ``` -------------------------------- ### Basic Prometheus Log Sink Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/prometheus.md Add the PrometheusLogSink to your logger and start the HTTP server to expose metrics. Ensure `prometheus-client` is installed to avoid `ModuleNotFoundError`. ```python from logly import logger from logly.integrations.prometheus import PrometheusLogSink from prometheus_client import start_http_server logger.add(PrometheusLogSink(), level="INFO") start_http_server(8000) ``` -------------------------------- ### Basic PostgreSQL Handler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/postgresql.md Configure the PostgresHandler with a connection string and table name. Add the handler to the logger to start sending WARNING level logs to PostgreSQL. ```python from logly import logger from logly.integrations.postgresql import PostgresHandler handler = PostgresHandler( "postgresql://user:pass@localhost:5432/logs", table="app_logs", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Install Logly from Source Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/getting-started.md Clone the Logly repository and install it from source using uv. ```bash git clone https://github.com/muhammad-fiaz/logly.git cd logly uv sync uv run maturin develop ``` -------------------------------- ### Basic Slack Handler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/slack.md Configure the SlackHandler to send logs to a specified channel and username. Ensure the 'slack-sdk' is installed to avoid ModuleNotFoundError. ```python from logly import logger from logly.integrations.slack import SlackHandler handler = SlackHandler( "https://hooks.slack.com/services/", channel="#logs", username="Logly Bot", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Install Dependencies Source: https://github.com/muhammad-fiaz/logly/blob/main/CONTRIBUTING.md Install all project dependencies using uv. ```bash uv sync ``` -------------------------------- ### Install Logly with uv Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/getting-started.md Install the Logly library using uv. ```bash uv add logly ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/configure.md A comprehensive example demonstrating the configuration of handlers, custom levels, extra context, a patcher function, and activation patterns in a single call. ```python from logly import logger logger.configure( handlers=[ {"sink": "stderr", "level": "INFO", "colorize": True}, {"sink": "logs/app.log", "level": "DEBUG", "rotation": "daily", "retention": "7 days"}, {"sink": "logs/errors.log", "level": "ERROR", "serialize": True}, ], levels=[ {"name": "SECURITY", "no": 45, "color": ""}, ], extra={"service": "api", "env": "prod"}, patcher=lambda r: r.setdefault("extra", {}).setdefault("region", "us-east-1"), activation=[ ("uvicorn.*", False), ("third_party.*", False), ], ) ``` -------------------------------- ### Install Prometheus Client Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/prometheus.md Install the Prometheus client library for Logly. Use the `[prometheus]` extra for Logly or install `prometheus-client` separately. ```bash uv add logly[prometheus] ``` ```bash pip install "logly[prometheus]" ``` ```bash uv add prometheus-client ``` ```bash pip install prometheus-client ``` -------------------------------- ### Full Slack Handler Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/slack.md A comprehensive example demonstrating the SlackHandler with custom webhook URL, channel, username, and icon emoji. This setup is useful for production alerts. ```python from logly import logger from logly.integrations.slack import SlackHandler handler = SlackHandler( webhook_url="https://hooks.slack.com/services/T00/B00/xxx", channel="#ops-alerts", username="Logly Alerts", icon_emoji=":warning:", ) logger.add(handler, level="WARNING") logger.warning("High memory usage detected", usage="87%") logger.error("Database connection pool exhausted") ``` -------------------------------- ### Install Logly with Click Support Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/click.md Install the Logly package with the Click extra or install Click separately. ```bash uv add logly[click] ``` ```bash pip install "logly[click]" ``` ```bash uv add click ``` ```bash pip install click ``` -------------------------------- ### Full Prometheus Log Sink Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/prometheus.md Configure the PrometheusLogSink with a custom namespace and log messages. This example demonstrates starting the metrics endpoint and logging various levels. ```python from logly import logger from logly.integrations.prometheus import PrometheusLogSink from prometheus_client import start_http_server logger.add(PrometheusLogSink(namespace="myapp"), level="INFO") # Start Prometheus metrics endpoint start_http_server(8000) logger.info("Application started") logger.warning("High memory usage") logger.error("Request failed") ``` -------------------------------- ### FastAPI Startup Event for Logging Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/uvicorn.md Integrate Logly logging into a FastAPI application by calling `setup_uvicorn_logging()` within the application's startup event. This ensures logging is configured before the application starts serving requests. ```python from fastapi import FastAPI from logly.integrations.uvicorn import setup_uvicorn_logging app = FastAPI() @app.on_event("startup") async def startup(): setup_uvicorn_logging() ``` -------------------------------- ### Install Logly with RQ support Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/rq.md Install the Logly package with the `rq` extra or install `rq` separately. ```bash uv add logly[rq] ``` ```bash pip install "logly[rq]" ``` ```bash uv add rq ``` ```bash pip install rq ``` -------------------------------- ### Quick Setup for RQ Logging Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/rq.md Use `setup_rq_logging()` for the simplest integration. This function configures both `rq` and `rq.worker` loggers. ```python from logly.integrations.rq import setup_rq_logging setup_rq_logging() ``` -------------------------------- ### Full Click Example with Logging Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/click.md A complete example demonstrating Click integration with Logly, including setting up a log file and logging messages at different levels. ```python import click from logly import logger from logly.integrations.click import click_echo click.echo = click_echo logger.add("cli.log", level="INFO") @click.command() @click.option("--name", prompt="Your name", help="The person to greet.") def hello(name): click.echo(f"Hello, {name}!") click.echo("Done!", err=True) if __name__ == "__main__": hello() ``` -------------------------------- ### Basic Redis Handler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/redis.md Configure the RedisHandler to push logs to a Redis list. Ensure the 'redis' package is installed to avoid ModuleNotFoundError. ```python from logly import logger from logly.integrations.redis import RedisHandler handler = RedisHandler( "redis://localhost:6379/0", key="app:logs", mode="list", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Basic Discord Handler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/discord.md Configure the `DiscordHandler` with your webhook URL and set the desired logging level. Add the handler to the logger to start sending messages. ```python from logly import logger from logly.integrations.discord import DiscordHandler handler = DiscordHandler( "https://discord.com/api/webhooks/", level="WARNING", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Install Logly with Poetry Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/getting-started.md Install the Logly library using Poetry. ```bash poetry add logly ``` -------------------------------- ### Basic FastAPI Setup with LoglyMiddleware Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/fastapi.md Add LoglyMiddleware to your FastAPI application to automatically enrich logs with request context. Ensure Logly is installed. ```python from fastapi import FastAPI from logly.integrations.fastapi import LoglyMiddleware app = FastAPI() app.add_middleware(LoglyMiddleware) @app.get("/") async def root(): logger.info("Root endpoint called") return {"message": "Hello World"} ``` -------------------------------- ### Basic KafkaHandler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/kafka.md Configure the KafkaHandler to publish logs to a specified Kafka topic. Ensure the confluent-kafka package is installed to avoid ModuleNotFoundError. ```python from logly import logger from logly.integrations.kafka import KafkaHandler handler = KafkaHandler( "localhost:9092", topic="app-logs", client_id="logly-producer", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Install Logly with Django Support Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/django.md Use uv or pip to install the logly package with Django extras, or install Django separately if not using extras. ```bash uv add logly[django] ``` ```bash pip install "logly[django]" ``` ```bash uv add django ``` ```bash pip install django ``` -------------------------------- ### Full Structlog Example with Custom Processors and Logly Renderer Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/structlog.md A comprehensive example demonstrating structlog configuration with custom processors like TimeStamper and ConsoleRenderer, and logging various levels. ```python import structlog from logly.integrations.structlog import logly_processor, LoglyRenderer structlog.configure( processors=[ structlog.contextvars.merge_contextvars, structlog.processors.add_log_level, structlog.processors.TimeStamper(fmt="iso"), structlog.dev.ConsoleRenderer(), ], logger_factory=structlog.PrintLoggerFactory(), wrapper_class=structlog.BoundLogger, ) log = structlog.get_logger() log.info("user_login", user_id=123, ip="192.168.1.1") log.warning("rate_limit_exceeded", endpoint="/api/users") log.error("database_connection_failed", host="db.example.com") ``` -------------------------------- ### Full Example with Custom Log File Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/rq.md Configure RQ logging with a specific level and add a custom log file for worker debug logs. Remember that RQ worker processes are forked, so configure logging after the worker starts. ```python import logging from logly import logger from logly.integrations.rq import setup_rq_logging setup_rq_logging(level="INFO") logger.add("worker.log", level="DEBUG", rotation="10 MB") ``` -------------------------------- ### Full KafkaHandler Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/kafka.md A comprehensive example demonstrating the KafkaHandler with custom bootstrap servers, topic, client ID, acknowledgments, and timeout. Use 'acks="all"' for maximum durability. ```python from logly import logger from logly.integrations.kafka import KafkaHandler handler = KafkaHandler( bootstrap_servers="broker1:9092,broker2:9092", topic="myapp-logs", client_id="myapp-service", acks="all", timeout=10.0, ) logger.add(handler, level="INFO") logger.info("Processing request", request_id="req-123") logger.error("Handler failed", error="timeout") ``` -------------------------------- ### Install Logly with uv or pip Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/faq.md Use uv or pip to install the Logly library. uv is the recommended package installer. ```bash # uv (recommended) uv add logly # pip pip install logly ``` -------------------------------- ### Setup Uvicorn Logging with Logly Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/api-reference/integrations.md Initializes Uvicorn logging with Logly's setup function. This allows for customized logging levels and formats for Uvicorn applications. ```python # uvicorn config from logly.integrations.uvicorn import setup_uvicorn_logging setup_uvicorn_logging(level="INFO") ``` -------------------------------- ### Full Django Settings Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/django.md A comprehensive example of Django settings including LoglyHandler and LoglyMiddleware along with other common Django middleware. ```python # settings.py from pathlib import Path LOGGING = { "version": 1, "disable_existing_loggers": False, "formatters": {}, "handlers": { "logly": { "class": "logly.integrations.django.LoglyHandler", "level": "INFO", }, }, "root": { "handlers": ["logly"], "level": "INFO", }, } MIDDLEWARE = [ "logly.integrations.django.LoglyMiddleware", "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", ] ``` -------------------------------- ### Install Gunicorn using uv Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/gunicorn.md Install Gunicorn using uv if you are not using the Logly extras. ```bash uv add gunicorn ``` -------------------------------- ### Development Environment Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/environment-variables.md For development, it's common to enable auto-initialization for immediate feedback. This sets LOGLY_AUTOINIT to true. ```bash export LOGLY_AUTOINIT=true ``` -------------------------------- ### Multiple Sinks Configuration Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/sinks.md An example demonstrating the configuration of multiple sinks for different purposes: console output, daily rotated application logs, error monitoring with serialization, and an audit trail with channel filtering. ```python from logly import logger # Console output logger.add("stderr", level="INFO", colorize=True) # Application logs logger.add( "logs/app.log", level="DEBUG", format="{time:YYYY-MM-DD HH:mm:ss} | {level:<8} | {message}", rotation="daily", retention="30 days", compression="gzip", ) # Error monitoring logger.add( "logs/errors.log", level="ERROR", rotation="daily", retention="90 days", serialize=True, ) # Audit trail logger.add( "logs/audit.log", level="INFO", filter={"channel": "audit"}, rotation="daily", retention="365 days", ) logger.info("This goes to console, app.log, and audit.log (if bound)") logger.error("This goes to console, app.log, and errors.log") logger.complete() ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/muhammad-fiaz/logly/blob/main/CONTRIBUTING.md Install pre-commit hooks to ensure code quality before committing. ```bash uv run pre-commit install ``` -------------------------------- ### Install Slack Integration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/slack.md Install the necessary package for the Slack integration. Choose the appropriate command based on your package manager. ```bash uv add logly[slack] ``` ```bash pip install "logly[slack]" ``` ```bash uv add slack-sdk ``` ```bash pip install slack-sdk ``` -------------------------------- ### Install Logly with Typer Support Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/typer.md Install the logly package with the Typer extra, or install Typer separately if not using Logly's extras. ```bash uv add logly[typer] ``` ```bash pip install "logly[typer]" ``` ```bash uv add typer ``` ```bash pip install typer ``` -------------------------------- ### Install Logly with Starlette Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/starlette.md Use the appropriate command to install the logly package with starlette extras or install starlette separately. ```bash uv add logly[starlette] ``` ```bash pip install "logly[starlette]" ``` ```bash uv add starlette ``` ```bash pip install starlette ``` -------------------------------- ### Install Logly with PostgreSQL Support Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/postgresql.md Install the Logly package with PostgreSQL extras using uv or pip. Alternatively, install psycopg2-binary separately if not using Logly extras. ```bash uv add logly[postgresql] ``` ```bash pip install "logly[postgresql]" ``` ```bash uv add psycopg2-binary ``` ```bash pip install psycopg2-binary ``` -------------------------------- ### Install Logly with pip Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/getting-started.md Install the Logly library using pip. ```bash pip install logly ``` -------------------------------- ### Install Logly with Uvicorn Support Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/uvicorn.md Install the Logly package with Uvicorn extras using uv or pip. Alternatively, install Uvicorn separately if not using Logly extras. ```bash uv add logly[uvicorn] ``` ```bash pip install "logly[uvicorn]" ``` ```bash uv add uvicorn ``` ```bash pip install uvicorn ``` -------------------------------- ### Full Uvicorn Example with Logly Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/uvicorn.md A complete example demonstrating a FastAPI application with Uvicorn, integrating Logly logging at the INFO level and running the server. ```python import uvicorn from fastapi import FastAPI from logly.integrations.uvicorn import setup_uvicorn_logging app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} if __name__ == "__main__": setup_uvicorn_logging(level="INFO") uvicorn.run("app:app", host="0.0.0.0", port=8000) ``` -------------------------------- ### Full Discord Handler Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/discord.md This example demonstrates setting up the `DiscordHandler` with a custom webhook URL, timeout, and username. It also shows how to add the handler to the logger with an 'ERROR' level and log a critical message. ```python from logly import logger from logly.integrations.discord import DiscordHandler handler = DiscordHandler( webhook_url="https://discord.com/api/webhooks/123/abc...", timeout=15.0, username="Production Alerts", ) logger.add(handler, level="ERROR") logger.critical("Service is down", service="api-gateway") ``` -------------------------------- ### Install Logly with Sentry Extras Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/sentry.md Install the Logly package with Sentry extras using uv or pip. Alternatively, install sentry-sdk separately if not using Logly extras. ```bash uv add logly[sentry] ``` ```bash pip install "logly[sentry]" ``` ```bash uv add sentry-sdk ``` ```bash pip install sentry-sdk ``` -------------------------------- ### Install OpenTelemetry packages manually (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/opentelemetry.md Use uv to install opentelemetry-api and opentelemetry-sdk if not using logly extras. ```bash uv add opentelemetry-api opentelemetry-sdk ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/muhammad-fiaz/logly/blob/main/CONTRIBUTING.md Build and serve the project documentation locally for preview. ```bash uv run mkdocs serve ``` -------------------------------- ### Full OpenTelemetry Log Export Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/opentelemetry.md Configure OTelLogSink with service name, endpoint, and protocol for exporting logs. This example sends INFO and ERROR level logs. ```python from logly import logger from logly.integrations.opentelemetry import OTelLogSink logger.add( OTelLogSink( service_name="my-api", endpoint="http://localhost:4318", protocol="http", ), level="INFO", ) logger.info("Request processed", user_id=123) logger.error("Database connection failed") ``` -------------------------------- ### Install SQLAlchemy separately Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/sqlalchemy.md Install SQLAlchemy without Logly extras if you only need the core library. ```bash uv add sqlalchemy ``` ```bash pip install sqlalchemy ``` -------------------------------- ### Full Flask Example with Logly Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/flask.md A complete example demonstrating the Flask integration with Logly, including routes for the index page and fetching items, with logging statements at different levels. Ensure `debug=True` is set for development. ```python from flask import Flask, jsonify from logly.integrations.flask import init_app from logly import logger app = Flask(__name__) init_app(app) @app.route("/") def index(): logger.info("Index page accessed") return jsonify({"message": "Hello World"}) @app.route("/items/") def get_item(item_id): logger.debug("Fetching item {}", item_id) return jsonify({"item_id": item_id}) if __name__ == "__main__": app.run(debug=True) ``` -------------------------------- ### Build Documentation Source: https://github.com/muhammad-fiaz/logly/blob/main/CONTRIBUTING.md Build the static documentation files for deployment. ```bash uv run mkdocs build ``` -------------------------------- ### Install FastAPI and Starlette Separately Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/fastapi.md If you prefer not to use extras, install FastAPI and Starlette manually. ```bash uv add fastapi starlette ``` ```bash pip install fastapi starlette ``` -------------------------------- ### Install Logly with OpenTelemetry support (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/opentelemetry.md Use uv to add the logly package with OpenTelemetry extras for installation. ```bash uv add logly[opentelemetry] ``` -------------------------------- ### Install APScheduler with Logly (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/apscheduler.md Install the apscheduler extra for logly using uv. ```bash uv add logly[apscheduler] ``` -------------------------------- ### Full MongoDB Integration Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/mongodb.md Demonstrates setting up the MongoHandler with custom connection details, database, collection, and timeout, then logging messages. ```python from logly import logger from logly.integrations.mongodb import MongoHandler handler = MongoHandler( uri="mongodb://user:pass@mongo-host:27017/", database="production", collection="app_logs", timeout=10.0, ) logger.add(handler, level="INFO") logger.info("User signed up", user_id="u-456") logger.exception("Payment failed") ``` -------------------------------- ### Basic Usage Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/redis.md Demonstrates the basic setup of the RedisHandler with default settings and adding it to the logger. ```APIDOC ## Basic Usage ### Description Example of initializing and using the RedisHandler with default settings. ### Method None (This is an SDK usage example) ### Endpoint None ### Parameters None ### Request Example ```python from logly import logger from logly.integrations.redis import RedisHandler handler = RedisHandler( "redis://localhost:6379/0", key="app:logs", mode="list", ) logger.add(handler, level="WARNING") ``` ### Response None ``` -------------------------------- ### Full Typer CLI Example with Logging Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/typer.md A complete example demonstrating how to integrate Logly's `typer_echo` into a Typer CLI application, including logging to a file and handling errors. ```python import typer from logly import logger from logly.integrations.typer import typer_echo typer.echo = typer_echo app = typer.Typer() logger.add("cli.log", level="INFO") @app.command() def greet(name: str): typer.echo(f"Hello, {name}!") typer.echo("Something went wrong", err=True) if __name__ == "__main__": app() ``` -------------------------------- ### Install Logly with SQLAlchemy extras Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/sqlalchemy.md Install the Logly package with the SQLAlchemy extra dependencies using uv or pip. ```bash uv add logly[sqlalchemy] ``` ```bash pip install "logly[sqlalchemy]" ``` -------------------------------- ### Full Example with HttpJsonSink and Custom Headers/Timeout Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/telemetry.md A comprehensive example demonstrating HttpJsonSink configuration with custom endpoint, authorization headers, and a specific timeout. Useful for secured HTTP endpoints. ```python from logly import logger from logly.integrations.telemetry import HttpJsonSink logger.add( HttpJsonSink( endpoint="http://localhost:8080/telemetry", headers={"Authorization": "Bearer token123"}, timeout=10.0, ), level="INFO", ) logger.info("Telemetry event", event_type="api_call", latency_ms=42) ``` -------------------------------- ### Setup Gunicorn Logging with Logly Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/api-reference/integrations.md Configures Gunicorn's logging using Logly's setup function. Specify the desired log level and optionally a custom format string. ```python # gunicorn.conf.py from logly.integrations.gunicorn import setup_gunicorn_logging setup_gunicorn_logging(level="INFO") ``` -------------------------------- ### Install Logly with FastAPI Extras Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/fastapi.md Use this command to install Logly with the necessary dependencies for FastAPI integration. ```bash uv add logly[fastapi] ``` ```bash pip install "logly[fastapi]" ``` -------------------------------- ### Full Production Logging Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/examples/production-config.md Configures application, error, and debug logs with daily rotation, retention policies, and compression. Use `enqueue=True` in production to prevent blocking application threads. This setup ensures disk usage is bounded while preserving logs for auditing. ```python import os from logly import logger LOG_DIR = os.environ.get("LOG_DIR", "logs") os.makedirs(LOG_DIR, exist_ok=True) # Application logs - daily rotation, 30-day retention, gzip logger.add( f"{LOG_DIR}/app.log", level="INFO", rotation="daily", retention="30 days", compression="gzip", serialize=True, enqueue=True, format="{time} | {level} | {name}:{function}:{line} - {message}", ) # Error logs - separate file, 90-day retention logger.add( f"{LOG_DIR}/errors.log", level="ERROR", rotation="daily", retention="90 days", compression="gzip", enqueue=True, ) # Debug logs - size-based, 3 copies logger.add( f"{LOG_DIR}/debug.log", level="DEBUG", rotation="50 MB", retention=3, enqueue=True, ) logger.info("Production logging configured") logger.complete() ``` -------------------------------- ### Docker Environment Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/environment-variables.md When using Docker, environment variables can be set using the ENV instruction in the Dockerfile. This example disables auto-initialization. ```dockerfile ENV LOGLY_AUTOINIT=false ``` -------------------------------- ### Basic MongoDB Handler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/mongodb.md Configure and add the MongoHandler to the logger for basic log entry insertion. ```python from logly import logger from logly.integrations.mongodb import MongoHandler handler = MongoHandler( "mongodb://localhost:27017", database="logs", collection="app_logs", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Install Logly with Structlog Support (pip) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/structlog.md Use pip to install the logly package with structlog extras. ```bash pip install "logly[structlog]" ``` -------------------------------- ### Full Email Handler Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/email.md A comprehensive example demonstrating the EmailHandler with custom subject prefix and critical log level. Remember to use application-specific passwords for authentication. ```python from logly import logger from logly.integrations.email import EmailHandler handler = EmailHandler( smtp_host="smtp.gmail.com", smtp_port=587, from_addr="alerts@myapp.com", to_addrs=["oncall@myapp.com", "team-lead@myapp.com"], username="alerts@myapp.com", password="xxxx-xxxx-xxxx-xxxx", use_tls=True, subject_prefix="[MyApp Alert]", ) logger.add(handler, level="CRITICAL") logger.critical("Payment processing is DOWN", service="payments") ``` -------------------------------- ### Quick Setup for PropagateHandler Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/propagate.md Add the PropagateHandler to the Logly logger for INFO level messages and above. This is the simplest way to start propagating logs. ```python from logly import logger from logly.integrations.propagate import PropagateHandler logger.add(PropagateHandler(), level="INFO") ``` -------------------------------- ### Manual Setup for RQ Logging Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/rq.md Manually add an `RQHandler` to the `rq` and `rq.worker` loggers if you need more control over the logging configuration. ```python import logging from logly.integrations.rq import RQHandler handler = RQHandler() logging.getLogger("rq").addHandler(handler) logging.getLogger("rq.worker").addHandler(handler) ``` -------------------------------- ### Full Starlette Example with Routes Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/starlette.md A complete Starlette application demonstrating routes, request handling, and LoglyMiddleware integration for logging. ```python from starlette.applications import Starlette from starlette.responses import JSONResponse from starlette.routing import Route from logly import logger from logly.integrations.starlette import LoglyMiddleware async def homepage(request): logger.info("Homepage accessed") return JSONResponse({"message": "Hello World"}) async def item(request): item_id = request.path_params["item_id"] logger.debug("Fetching item {}", item_id) return JSONResponse({"item_id": item_id}) app = Starlette(routes=[ Route("/", homepage), Route("/items/{item_id}", item), ]) app.add_middleware(LoglyMiddleware) ``` -------------------------------- ### Full PostgreSQL Logly Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/postgresql.md Demonstrates setting up the PostgresHandler with a specific DSN, table name, and enabling table creation. It then logs INFO and ERROR messages. ```python from logly import logger from logly.integrations.postgresql import PostgresHandler handler = PostgresHandler( dsn="postgresql://dbuser:dbpass@db-host:5432/myapp", table="app_logs", create_table=True, ) logger.add(handler, level="INFO") logger.info("Order created", order_id="ord-789") logger.error("Inventory sync failed") ``` -------------------------------- ### Install Logly with Structlog Support (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/structlog.md Use uv to add the logly package with structlog extras. ```bash uv add logly[structlog] ``` -------------------------------- ### Basic Loki Sink Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/loki.md Configure the logger to send INFO level logs to Loki with default labels. ```python from logly import logger from logly.integrations.loki import LokiSink logger.add( LokiSink( "http://localhost:3100/loki/api/v1/push", labels={"app": "myapp", "env": "production"}, ), level="INFO", ) ``` -------------------------------- ### Catch All Logly Errors Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/api-reference/exceptions.md Demonstrates a pattern for catching any LoglyError during logger setup or operation. This is useful for a global error handler in your application. ```python from logly.exceptions import LoglyError try: logger.add("app.log", rotation="daily") logger.info("Application started") except LoglyError as e: print(f"Logging error: {e}") ``` -------------------------------- ### Basic Logly Rich Sink Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/rich-console.md Demonstrates adding the LoglyRichSink to the logger for basic colored console output. Remember to remove the sink when done. ```python from logly import logger from logly.integrations.rich import LoglyRichSink sink_id = logger.add(LoglyRichSink(), colorize=True) logger.info("Rich-formatted output!") logger.success("Operation completed!") logger.error("Something went wrong") logger.complete() logger.remove(sink_id) ``` -------------------------------- ### Basic Sentry Sink Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/sentry.md Add the SentrySink to your Logly logger to capture WARNING level logs and above as Sentry events. Ensure you have the sentry-sdk installed. ```python from logly import logger from logly.integrations.sentry import SentrySink logger.add(SentrySink(dsn="https://...@sentry.io/..."), level="WARNING") ``` -------------------------------- ### Full Loki Sink Configuration Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/loki.md Demonstrates configuring LokiSink with endpoint, custom labels, timeout, and basic authentication. Logs are sent with INFO and ERROR levels. ```python from logly import logger from logly.integrations.loki import LokiSink logger.add( LokiSink( endpoint="http://loki:3100/loki/api/v1/push", labels={"app": "myapi", "env": "production", "region": "us-east-1"}, timeout=10.0, username="admin", password="secret", ), level="INFO", ) logger.info("User signed in", user_id=123) logger.error("Payment failed", order_id="abc-123") ``` -------------------------------- ### Basic Structlog Setup with Logly Processor Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/structlog.md Configure structlog to use Logly's processor for basic logging. This setup routes log messages through Logly's processing pipeline. ```python import structlog from logly.integrations.structlog import logly_processor structlog.configure( processors=logly_processor(), logger_factory=structlog.PrintLoggerFactory(), ) log = structlog.get_logger() log.info("hello", key="value") ``` -------------------------------- ### Install Structlog Only (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/structlog.md Use uv to add only the structlog package if logly extras are not needed. ```bash uv add structlog ``` -------------------------------- ### Install Logly with Gunicorn support (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/gunicorn.md Use this command to add the Logly package with Gunicorn extras using uv. ```bash uv add logly[gunicorn] ``` -------------------------------- ### Full Redis Integration Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/redis.md Demonstrates setting up Logly with Redis using both list and stream modes. The list mode is configured with a maximum length, while the stream mode is set up for error logging. ```python from logly import logger from logly.integrations.redis import RedisHandler # List mode handler = RedisHandler( "redis://localhost:6379/0", key="app:logs", mode="list", max_stream_len=5000, ) logger.add(handler, level="WARNING") # Stream mode stream_handler = RedisHandler( "redis://localhost:6379/0", key="app:logs:stream", mode="stream", max_stream_len=10000, ) logger.add(stream_handler, level="ERROR") logger.warning("Disk usage critical") logger.error("Connection pool exhausted") ``` -------------------------------- ### Logging User Data in Flask Route Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/flask.md Example of logging user information within a Flask route. Logs automatically include request context like request_id, method, and path when LoglyMiddleware or manual setup is used. ```python @app.route("/users/") def get_user(user_id): logger.info("Fetching user {}", user_id) # Logs include: request_id, method, path from context return {"user_id": user_id} ``` -------------------------------- ### Basic Configuration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/configure.md Use logger.configure() to set up initial handlers for different log levels. This replaces any existing handlers. ```python from logly import logger logger.configure( handlers=[ {"sink": "stderr", "level": "INFO"}, {"sink": "app.log", "level": "DEBUG", "rotation": "daily"}, ], ) ``` -------------------------------- ### Install Kafka Integration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/kafka.md Install the Kafka integration for Logly using pip or uv. You can install with extras or install the confluent-kafka package separately. ```bash uv add logly[kafka] ``` ```bash pip install "logly[kafka]" ``` ```bash uv add confluent-kafka ``` ```bash pip install confluent-kafka ``` -------------------------------- ### Install Elasticsearch Package Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/elasticsearch.md Install the necessary package for Elasticsearch integration using either uv or pip. You can install with extras or separately install the `elasticsearch` package. ```bash uv add logly[elasticsearch] ``` ```bash pip install "logly[elasticsearch]" ``` ```bash uv add elasticsearch ``` ```bash pip install elasticsearch ``` -------------------------------- ### Setup RQ logging with a specific level Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/api-reference/integrations.md Configure RQ logging by calling setup_rq_logging with the desired minimum log level. The default level is INFO. ```python from logly.integrations.rq import setup_rq_logging setup_rq_logging(level="INFO") ``` -------------------------------- ### Install Discord Integration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/discord.md Install the Discord integration for Logly using either `uv` or `pip`. If you are not installing Logly with extras, you need to install `aiohttp` separately. ```bash uv add logly[discord] ``` ```bash pip install "logly[discord]" ``` ```bash uv add aiohttp ``` ```bash pip install aiohttp ``` -------------------------------- ### Install MongoDB Integration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/mongodb.md Install the Logly package with MongoDB extras or install pymongo separately. ```bash uv add logly[mongodb] ``` ```bash pip install "logly[mongodb]" ``` ```bash uv add pymongo ``` ```bash pip install pymongo ``` -------------------------------- ### setup_uvicorn_logging Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/api-reference/integrations.md Sets up Logly logging for Uvicorn. ```APIDOC ## setup_uvicorn_logging ### Description Sets up Logly logging for Uvicorn. ### Parameters #### Parameters - **level** (str) - Optional - Minimum log level (default: "INFO") - **format** (str | None) - Optional - Custom format string (default: None) ### Usage ```python # uvicorn config from logly.integrations.uvicorn import setup_uvicorn_logging setup_uvicorn_logging(level="INFO") ``` ``` -------------------------------- ### Basic RabbitMQ Handler Setup Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/rabbitmq.md Configure the RabbitMQHandler with a connection URL and queue name. Connections are established lazily on the first write. ```python from logly import logger from logly.integrations.rabbitmq import RabbitMQHandler handler = RabbitMQHandler( "amqp://guest:guest@localhost:5672/", queue="app-logs", ) logger.add(handler, level="WARNING") ``` -------------------------------- ### Install Rich Dependency Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/rich.md Install the 'rich' package to enable Rich console output. You can install it as an extra with Logly or separately. ```bash uv add logly[rich] ``` ```bash pip install "logly[rich]" ``` ```bash uv add rich ``` ```bash pip install rich ``` -------------------------------- ### Full Stdlib Logging Example Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/stdlib.md Demonstrates configuring both the root logger and specific loggers (e.g., 'uvicorn', 'werkzeug', 'sqlalchemy') to use InterceptHandler. Also shows how to disable propagation for specific loggers and use standard logging functions. ```python import logging from logly import logger from logly.integrations.stdlib import InterceptHandler # Configure root logger logging.basicConfig( handlers=[InterceptHandler()], level=logging.INFO, ) # Route specific loggers for name in ("uvicorn", "werkzeug", "sqlalchemy"): log = logging.getLogger(name) log.handlers = [InterceptHandler()] log.propagate = False # Use stdlib logging normally logging.info("Application started") logging.warning("Something seems off") logging.error("Something went wrong") ``` -------------------------------- ### Configuration Comparison (Python) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/switching-from-other-libraries.md Compare the setup of basic logging configurations using stdlib's basicConfig versus Logly's add method for multiple handlers. ```python # Before (stdlib) logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", handlers=[ logging.StreamHandler(), logging.FileHandler("app.log"), ] ) # After (Logly) from logly import logger logger.add(sys.stderr, level="INFO") logger.add("app.log", level="INFO") ``` -------------------------------- ### Full Example: Propagating Logs to Stdlib and File Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/propagate.md Demonstrates configuring both standard library logging and a Logly file handler, then propagating Logly messages to both. Use this to see Logly output in both the console (via stdlib) and a file. ```python import logging from logly import logger from logly.integrations.propagate import PropagateHandler logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") logger.add(PropagateHandler(name="myapp"), level="INFO") logger.add("app.log", level="DEBUG", rotation="10 MB") logger.info("This appears in both Logly file and stdlib console output") ``` -------------------------------- ### Install Redis Package Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/redis.md Install the necessary package for Redis integration using either uv or pip. You can install with extras or separately. ```bash uv add logly[redis] ``` ```bash pip install "logly[redis]" ``` ```bash uv add redis ``` ```bash pip install redis ``` -------------------------------- ### Install Flask Integration Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/flask.md Install the Logly Flask integration using pip or uv. Ensure Flask is installed separately if not using the extras. ```bash uv add logly[flask] ``` ```bash pip install "logly[flask]" ``` ```bash uv add flask ``` ```bash pip install flask ``` -------------------------------- ### Time-Based Rotation Examples Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/rotation-retention-compression.md Set up log file rotation at fixed time intervals. Supported intervals include daily, hourly, weekly, monthly, yearly, and minutely. ```python from logly import logger # Daily rotation logger.add("app.log", rotation="daily") # Hourly rotation logger.add("app.log", rotation="hourly") # Weekly rotation logger.add("app.log", rotation="weekly") # Monthly rotation logger.add("app.log", rotation="monthly") # Yearly rotation logger.add("app.log", rotation="yearly") # Every minute logger.add("app.log", rotation="minutely") ``` -------------------------------- ### Production Log Setup with Rotation, Retention, and Compression Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/guides/rotation-retention-compression.md Configure application, error, and debug logs with daily rotation, specific retention periods, and gzip compression. Error logs are serialized for easier parsing. ```python from logly import logger # Application logs logger.add( "logs/app.log", level="INFO", format="{time:YYYY-MM-DD HH:mm:ss} | {level:<8} | {message}", rotation="daily", retention="30 days", compression="gzip", ) # Error logs logger.add( "logs/errors.log", level="ERROR", rotation="daily", retention="90 days", compression="gzip", serialize=True, ) # Debug logs (development) logger.add( "logs/debug.log", level="DEBUG", rotation="10 MB", retention=5, ) ``` -------------------------------- ### setup_gunicorn_logging Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/api-reference/integrations.md Sets up Logly logging for Gunicorn. ```APIDOC ## setup_gunicorn_logging ### Description Sets up Logly logging for Gunicorn. ### Parameters #### Parameters - **level** (str) - Optional - Minimum log level (default: "INFO") - **format** (str | None) - Optional - Custom format string (default: None) ### Usage ```python # gunicorn.conf.py from logly.integrations.gunicorn import setup_gunicorn_logging setup_gunicorn_logging(level="INFO") ``` ``` -------------------------------- ### Configure File Logging Source: https://github.com/muhammad-fiaz/logly/blob/main/README.md Set up logging to a file with daily rotation, 30-day retention, and gzip compression. ```python from logly import logger logger.add( "logs/app.log", level="INFO", rotation="daily", retention="30 days", compression="gzip", ) logger.info("Application started") logger.complete() ``` -------------------------------- ### Install APScheduler only (pip) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/apscheduler.md Install apscheduler using pip if logly extras are not needed. ```bash pip install apscheduler ``` -------------------------------- ### Install APScheduler only (uv) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/apscheduler.md Install apscheduler using uv if logly extras are not needed. ```bash uv add apscheduler ``` -------------------------------- ### Install APScheduler with Logly (pip) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/apscheduler.md Install the apscheduler extra for logly using pip. ```bash pip install "logly[apscheduler]" ``` -------------------------------- ### Create Virtual Environment Source: https://github.com/muhammad-fiaz/logly/blob/main/CONTRIBUTING.md Create a new virtual environment using uv. ```bash uv venv ``` -------------------------------- ### Install Structlog Only (pip) Source: https://github.com/muhammad-fiaz/logly/blob/main/docs/integrations/structlog.md Use pip to install only the structlog package if logly extras are not needed. ```bash pip install structlog ```