Skip to content
Snippets Groups Projects
Commit 1270274d authored by supersonicwisd1's avatar supersonicwisd1
Browse files

added utils dir

Signed-off-by: supersonicwisd1 <supersonicwisd1>
parent 514f9ed1
No related branches found
No related tags found
1 merge request!6Model Definition and Testing for ActivityPub (Code Structure Changed)
class ActivityPubException(Exception):
"""Base exception for ActivityPub-related errors."""
class ValidationError(ActivityPubException):
"""Raised when validation fails."""
class DeserializationError(ActivityPubException):
"""Raised when deserialization fails."""
class RemoteObjectFetchError(ActivityPubException):
"""Raised when fetching a remote object fails."""
class InvalidURLError(ValidationError):
"""Raised when an invalid URL is provided."""
class InvalidDateTimeError(ValidationError):
"""Raised when an invalid date/time is provided."""
class SignatureVerificationError(ActivityPubException):
"""Raised when signature verification fails."""
pass
class SignatureError(ActivityPubException):
"""Raised when signature verification fails."""
pass
class AuthenticationError(ActivityPubException):
"""Raised when signature verification fails."""
pass
class RateLimitExceeded(ActivityPubException):
"""Raised when signature verification fails."""
pass
class WebFingerError(ActivityPubException):
"""Raised when signature verification fails."""
pass
class SecurityError(ActivityPubException):
"""Raised when signature verification fails."""
pass
import logging
import sys
from typing import Optional
def configure_logging(level: Optional[str] = None):
"""
Configure the logging system for the ActivityPub library.
Args:
level (Optional[str]): The logging level. If None, defaults to INFO.
"""
if level is None:
level = logging.INFO
else:
level = getattr(logging, level.upper())
logging.basicConfig(
level=level,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler('activitypub_library.log')
]
)
def get_logger(name: str) -> logging.Logger:
"""
Get a logger with the specified name.
Args:
name (str): The name of the logger, typically __name__ of the module.
Returns:
logging.Logger: A configured logger instance.
"""
return logging.getLogger(name)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment