Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github: ddc
ko_fi: ddcsta
ko_fi: ddc
custom: "https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ"
3 changes: 0 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
## Summary
<!-- Brief description of what this PR does and why -->

## Changes Made
<!-- List the key changes -->

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --locked --all-extras --group dev
run: uv sync --locked --all-extras --all-groups

- name: Run tests with coverage
uses: nick-fields/retry@v3
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<a href="https://ko-fi.com/ddc"><img src="https://img.shields.io/badge/Ko--fi-ddc-FF5E5B?style=plastic&logo=kofi&logoColor=white&color=brightgreen" alt="Ko-fi"/></a>
<a href="https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ"><img src="https://img.shields.io/badge/Donate-PayPal-brightgreen.svg?style=plastic&logo=paypal&logoColor=white" alt="Donate"/></a>
<br>
<a href="https://pypi.python.org/pypi/pythonlogs"><img src="https://img.shields.io/pypi/v/pythonlogs.svg?style=plastic&logo=python&cacheSeconds=3600" alt="PyPi"/></a>
<a href="https://pepy.tech/projects/pythonlogs"><img src="https://img.shields.io/pepy/dt/pythonlogs?style=plastic&logo=pypi&logoColor=3776AB" alt="PyPI Downloads"/></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=plastic&logo=creativecommons&logoColor=white" alt="License: MIT"/></a>
<br>
<a href="https://www.python.org/downloads"><img src="https://img.shields.io/pypi/pyversions/pythonlogs.svg?style=plastic&logo=python&cacheSeconds=3600" alt="Python"/></a>
<a href="https://github.com/astral-sh/uv"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=plastic" alt="uv"/></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=plastic" alt="Ruff"/></a>
<br>
<a href="https://pypi.python.org/pypi/pythonlogs"><img src="https://img.shields.io/pypi/v/pythonlogs.svg?style=plastic&logo=python&cacheSeconds=3600" alt="PyPi"/></a>
<a href="https://pepy.tech/projects/pythonlogs"><img src="https://img.shields.io/pepy/dt/pythonlogs?style=plastic&logo=pypi&logoColor=3776AB" alt="PyPI Downloads"/></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=plastic&logo=creativecommons&logoColor=white" alt="License: MIT"/></a>
<br>
<a href="https://github.com/ddc/pythonlogs/issues"><img src="https://img.shields.io/github/issues/ddc/pythonlogs?style=plastic&logo=github&logoColor=white" alt="issues"/></a>
<a href="https://codecov.io/gh/ddc/pythonlogs"><img src="https://img.shields.io/codecov/c/github/ddc/pythonlogs?token=XWB53034GI&style=plastic&logo=codecov" alt="codecov"/></a>
<a href="https://sonarcloud.io/dashboard?id=ddc_pythonlogs"><img src="https://img.shields.io/sonar/quality_gate/ddc_pythonlogs?server=https%3A%2F%2Fsonarcloud.io&style=plastic&logo=sonarqubecloud&logoColor=white" alt="Quality Gate Status"/></a>
Expand Down Expand Up @@ -285,7 +285,6 @@ LOG_MAX_FILE_SIZE_MB=10

# TimedRotatingLog
LOG_ROTATE_WHEN=midnight
LOG_ROTATE_AT_UTC=True
LOG_ROTATE_FILE_SUFIX="%Y%m%d"
```

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages = ["pythonlogs"]

[project]
name = "pythonlogs"
version = "7.0.0"
version = "7.0.1"
description = "High-performance Python logging library with file rotation and optimized caching for better performance"
urls.Repository = "https://github.com/ddc/pythonlogs"
urls.Homepage = "https://pypi.org/project/pythonlogs"
Expand Down Expand Up @@ -51,9 +51,9 @@ dependencies = [
[dependency-groups]
dev = [
"psutil>=7.2.2",
"pytest-cov>=7.0.0",
"poethepoet>=0.42.1",
"ruff>=0.15.7",
"pytest-cov>=7.1.0",
"poethepoet>=0.43.0",
"ruff>=0.15.9",
]

[tool.poe.tasks]
Expand All @@ -62,7 +62,7 @@ snyk-export.shell = "rm -f requirements.txt && uv export --no-hashes --no-annota
snyk.sequence = ["snyk-export", { shell = "uv pip install pip && snyk test --file=requirements.txt && snyk code test; uv pip uninstall pip" }]
profile = "uv run python -m cProfile -o cprofile_unit.prof -m pytest --no-cov"
tests.sequence = ["linter", {shell = "uv run pytest"}]
updatedev.sequence = ["linter", {shell = "uv lock --upgrade && uv sync --all-extras --group dev"}]
updatedev.sequence = ["linter", {shell = "uv lock --upgrade && uv sync --all-extras --all-groups"}]
build.sequence = ["updatedev", "tests", {shell = "uv build --wheel"}]

[tool.pytest.ini_options]
Expand Down
1 change: 0 additions & 1 deletion pythonlogs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ LOG_MAX_FILE_SIZE_MB=10

# TimedRotatingLog Settings (only needed when using TimedRotatingLog)
LOG_ROTATE_WHEN=midnight
LOG_ROTATE_AT_UTC=True
LOG_ROTATE_FILE_SUFIX=%Y%m%d


Expand Down
17 changes: 9 additions & 8 deletions pythonlogs/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import logging
from enum import StrEnum
from typing import Final

# File and Directory Constants
MB_TO_BYTES = 1024 * 1024
DEFAULT_FILE_MODE = 0o755
DEFAULT_BACKUP_COUNT = 30
MB_TO_BYTES: Final = 1024 * 1024
DEFAULT_FILE_MODE: Final = 0o755
DEFAULT_BACKUP_COUNT: Final = 30

# Date Format Constants
DEFAULT_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"
DEFAULT_ROTATE_SUFFIX = "%Y%m%d"
DEFAULT_DATE_FORMAT: Final = "%Y-%m-%dT%H:%M:%S"
DEFAULT_ROTATE_SUFFIX: Final = "%Y%m%d"

# Encoding Constants
DEFAULT_ENCODING = "UTF-8"
DEFAULT_ENCODING: Final = "UTF-8"

# Timezone Constants
DEFAULT_TIMEZONE = "UTC"
DEFAULT_TIMEZONE: Final = "UTC"


class LogLevel(StrEnum):
Expand Down Expand Up @@ -45,7 +46,7 @@ class RotateWhen(StrEnum):


# Level mapping for performance optimization
LEVEL_MAP = {
LEVEL_MAP: Final = {
LogLevel.DEBUG.value.lower(): logging.DEBUG,
LogLevel.WARNING.value.lower(): logging.WARNING,
LogLevel.WARN.value.lower(): logging.WARNING,
Expand Down
4 changes: 0 additions & 4 deletions pythonlogs/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class LoggerConfig:
maxmbytes: int | None = None
when: RotateWhen | str | None = None
sufix: str | None = None
rotateatutc: bool | None = None
daystokeep: int | None = None


Expand Down Expand Up @@ -254,7 +253,6 @@ def get_memory_limits(cls) -> dict[str, int]:
"timezone",
"streamhandler",
"showlocation",
"rotateatutc",
},
),
}
Expand Down Expand Up @@ -426,7 +424,6 @@ def __init__(
timezone: str | None = None,
streamhandler: bool | None = None,
showlocation: bool | None = None,
rotateatutc: bool | None = None,
):
self._logger = LoggerFactory.create_logger(
LoggerType.TIMED_ROTATING,
Expand All @@ -442,7 +439,6 @@ def __init__(
timezone=timezone,
streamhandler=streamhandler,
showlocation=showlocation,
rotateatutc=rotateatutc,
)
self._name = name or get_log_settings().appname

Expand Down
4 changes: 0 additions & 4 deletions pythonlogs/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ class LogSettings(BaseSettings):
default=RotateWhen.MIDNIGHT,
description="When to rotate log files (midnight, hourly, daily, weekly)",
)
rotate_at_utc: bool = Field(
default=True,
description="Use UTC time for rotation timing",
)
rotate_file_sufix: str = Field(
default=DEFAULT_ROTATE_SUFFIX,
description="Date suffix format for rotated log files",
Expand Down
3 changes: 1 addition & 2 deletions pythonlogs/timed_rotating.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
timezone: str | None = None,
streamhandler: bool | None = None,
showlocation: bool | None = None,
rotateatutc: bool | None = None,
):
_settings = get_log_settings()
self.level = get_level(level or _settings.level)
Expand All @@ -58,7 +57,7 @@ def __init__(
self.timezone = timezone or _settings.timezone
self.streamhandler = streamhandler or _settings.stream_handler
self.showlocation = showlocation or _settings.show_location
self.rotateatutc = rotateatutc or _settings.rotate_at_utc
self.rotateatutc = self.timezone.upper() == "UTC"
self.logger = None

def init(self):
Expand Down
1 change: 0 additions & 1 deletion tests/core/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def test_default_values(self):
assert settings.logger_ttl_seconds == 3600
assert settings.max_file_size_mb == 10
assert settings.rotate_when.value == "midnight"
assert settings.rotate_at_utc is True
assert settings.rotate_file_sufix == DEFAULT_ROTATE_SUFFIX
finally:
# Restore environment variables
Expand Down
1 change: 0 additions & 1 deletion tests/factory/test_factory_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def test_logger_customization_example(self):
timezone="UTC",
streamhandler=True,
showlocation=True,
rotateatutc=True,
)

# Test all log levels
Expand Down
1 change: 0 additions & 1 deletion tests/factory/test_factory_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ def test_logger_customization_example_windows(self):
timezone="UTC",
streamhandler=True,
showlocation=True,
rotateatutc=True,
)

# Test all log levels
Expand Down
4 changes: 1 addition & 3 deletions tests/logger_types/test_timed_rotating.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def test_timed_rotating_log_initialization_with_all_params(self):
timezone="UTC",
streamhandler=True,
showlocation=True,
rotateatutc=True,
)
assert timed_log.appname == "test_comprehensive"
assert timed_log.filenames == ["test1.log", "test2.log"]
Expand Down Expand Up @@ -250,7 +249,7 @@ def test_timed_rotating_log_with_custom_suffix(self):
def test_timed_rotating_log_utc_rotation(self):
"""Test TimedRotatingLog with UTC rotation."""
with tempfile.TemporaryDirectory() as temp_dir:
timed_log = TimedRotatingLog(name="test_utc", directory=temp_dir, rotateatutc=True)
timed_log = TimedRotatingLog(name="test_utc", directory=temp_dir, timezone="UTC")
logger = timed_log.init()

# Check that handler is configured for UTC
Expand Down Expand Up @@ -466,7 +465,6 @@ def test_timed_rotating_log_handler_configuration(self):
encoding="utf-8",
when="H",
daystokeep=10,
# Note: rotateatutc defaults to True from settings
)
logger = timed_log.init()

Expand Down
Loading
Loading