Skip to content

Commit

Permalink
Merge pull request #47 from cdot65/46-duplicate-log-entries-in-script…
Browse files Browse the repository at this point in the history
…-execution-due-to-logger-propagation

Refactor logging configuration
  • Loading branch information
cdot65 authored Jan 22, 2024
2 parents 6521e90 + 59f45fd commit 88285ea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
7 changes: 2 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ RUN apk add --no-cache gcc musl-dev libffi-dev make
# Set the working directory in the container to /app
WORKDIR /app

# Copy the requirements file into the container at /app
COPY requirements.txt /app/

# Install any needed packages specified in requirements.txt
# Note: The requirements.txt should contain pan-os-upgrade==0.2.3
RUN pip install --no-cache-dir pan-os-upgrade==0.2.3
# Note: The requirements.txt should contain pan-os-upgrade==0.2.4
RUN pip install --no-cache-dir pan-os-upgrade==0.2.4

# Set the locale to avoid issues with emoji rendering
ENV LANG C.UTF-8
Expand Down
1 change: 0 additions & 1 deletion docker/requirements.txt

This file was deleted.

19 changes: 17 additions & 2 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

Welcome to the release notes for the `pan-os-upgrade` tool. This document provides a detailed record of changes, enhancements, and fixes in each version of the tool.

## Version 0.2.3
## Version 0.2.4

**Release Date:** *<20240122>*

### What's New

- Resolved a bug where console logging was duplicated
- Simplified the non-debug console log output
- Removed `requirements.txt` from Docker container image

## Version 0.2.4

**Release Date:** *<20240121>*

<!-- trunk-ignore(markdownlint/MD024) -->
### What's New

- Improved error handling for network layer transport.
Expand All @@ -15,6 +26,7 @@ Welcome to the release notes for the `pan-os-upgrade` tool. This document provid

**Release Date:** *<20240121>*

<!-- trunk-ignore(markdownlint/MD024) -->
### What's New

- Optimized for Docker execution.
Expand All @@ -24,6 +36,7 @@ Welcome to the release notes for the `pan-os-upgrade` tool. This document provid

**Release Date:** *<20240121>*

<!-- trunk-ignore(markdownlint/MD024) -->
### What's New

- Adjusting the execution of our script to instead reference the Typer app `app()` instead of `main()`.
Expand All @@ -33,6 +46,7 @@ Welcome to the release notes for the `pan-os-upgrade` tool. This document provid

**Release Date:** *<20240121>*

<!-- trunk-ignore(markdownlint/MD024) -->
### What's New

- Allow for simply running `pan-os-upgrade` without arguments, providing an interactive prompt for missing variables
Expand All @@ -50,7 +64,8 @@ Welcome to the release notes for the `pan-os-upgrade` tool. This document provid

**Release Date:** *<20240119>*

### Highlights
<!-- trunk-ignore(markdownlint/MD024) -->
### What's New

- First official release of the `pan-os-upgrade` tool on PyPi.
- Made available for wide usage and distribution.
Expand Down
11 changes: 7 additions & 4 deletions pan_os_upgrade/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,14 @@ def configure_logging(level: str) -> None:
"""
logging_level = getattr(logging, level.upper(), None)

# Create a logger
# Get the root logger
logger = logging.getLogger()
logger.setLevel(logging_level)

# Remove any existing handlers
for handler in logger.handlers[:]:
logger.removeHandler(handler)

# Create handlers (console and file handler)
console_handler = logging.StreamHandler()
file_handler = RotatingFileHandler(
Expand All @@ -288,12 +292,11 @@ def configure_logging(level: str) -> None:
"%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
else:
console_format = logging.Formatter(
"%(levelname)s - %(message)s",
)
console_format = logging.Formatter("%(message)s")
file_format = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)

console_handler.setFormatter(console_format)
file_handler.setFormatter(file_format)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pan-os-upgrade"
version = "0.2.3"
version = "0.2.4"
description = "Python script to automate the upgrade process of PAN-OS firewalls."
authors = ["Calvin Remsburg <cremsburg.dev@gmail.com>"]
license = "Apache 2.0"
Expand Down

0 comments on commit 88285ea

Please sign in to comment.