Skip to content

Commit 05339d4

Browse files
authored
Merge pull request #384 from networktocode/release/3.0.0
Release v3.0.0
2 parents 9ca4c9d + 265e35c commit 05339d4

7 files changed

Lines changed: 102 additions & 63 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# v3.0 Release Notes
2+
3+
This document describes all new features and changes in the release. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4+
5+
## Release Overview
6+
7+
- Pyntc now requires the `PYNTC_LOG_FILE` environment variable to output logging to a file. The new default behavior is to only log to stderr.
8+
9+
<!-- towncrier release notes start -->
10+
## [v3.0.0 (2026-05-06)](https://github.com/networktocode/pyntc/releases/tag/v3.0.0)
11+
12+
### Breaking Changes
13+
14+
- [#383](https://github.com/networktocode/pyntc/issues/383) - The pyntc rotating file handler is now opt-in via the `PYNTC_LOG_FILE` environment variable. When unset, no log file is created. When set, its value is used as the log file path, and the handler is registered only once per logger to avoid duplicate entries on repeated `get_log` calls.

docs/user/lib_getting_started.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,23 @@ Full workflow example:
342342
>>>
343343
```
344344

345+
# Logging
346+
347+
pyntc reads several environment variables to configure logging. None of them are required; all are read at runtime.
348+
349+
| Variable | Description |
350+
| --- | --- |
351+
| `PYNTC_LOG_LEVEL` | Log level for the `pyntc` logger (e.g. `debug`, `info`, `warning`). Defaults to `info`. |
352+
| `PYNTC_DEBUG` | When set to any non-empty value, forces the log level to `DEBUG` and switches to a more verbose log format. |
353+
| `PYNTC_LOG_FILE` | Path to a file that pyntc should log to. When set, a `RotatingFileHandler` (2000 byte rotation) is attached to the logger using this path. When unset, no file handler is attached; log records still propagate to the root logger configured by `logging.basicConfig` (called from `pyntc.log.init` during device initialization) or by the calling application. |
354+
355+
Example:
356+
357+
```bash
358+
export PYNTC_LOG_FILE=/var/log/pyntc.log
359+
export PYNTC_LOG_LEVEL=debug
360+
```
361+
345362
#### Cisco IOS Install Mode Option
346363

347364
New in 0.15 there is support for [Install Mode](https://content.cisco.com/chapter.sjs?uri=/searchable/chapter/c/en/us/td/docs/switches/lan/Denali_16-1/ConfigExamples_Technotes/Config_Examples/Misc/qos/m_install_vs_bundle.html.xml) upgrades. To execute this there is an option (defaults to False) to run install mode. **file_copy must be executed before install_os**

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ nav:
132132
- Uninstall: "admin/uninstall.md"
133133
- Release Notes:
134134
- "admin/release_notes/index.md"
135+
- v3.0: "admin/release_notes/version_3.0.md"
135136
- v2.4: "admin/release_notes/version_2.4.md"
136137
- v2.3: "admin/release_notes/version_2.3.md"
137138
- v2.2: "admin/release_notes/version_2.2.md"

poetry.lock

Lines changed: 56 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyntc/log.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,25 @@
1717
def get_log(name=None):
1818
"""Get log namespace and creates logger and rotating file handler.
1919
20+
A :class:`RotatingFileHandler` is attached if the ``PYNTC_LOG_FILE``
21+
environment variable is set, in which case its value is used as the log
22+
file path.
23+
2024
Args:
2125
name (str, optional): Sublogger name. Defaults to None.
2226
2327
Returns:
2428
(logger): Return a logger instance in the :data:`APP` namespace.
2529
"""
2630
logger_name = f"{APP}.{name}" if name else APP
27-
# file handler
28-
handler = RotatingFileHandler(f"{logger_name}.log", maxBytes=2000)
2931
_logger = logging.getLogger(logger_name)
30-
_logger.addHandler(handler)
32+
33+
log_file = os.environ.get("PYNTC_LOG_FILE")
34+
if log_file and not any(
35+
isinstance(h, RotatingFileHandler) and getattr(h, "baseFilename", None) == os.path.abspath(log_file)
36+
for h in _logger.handlers
37+
):
38+
_logger.addHandler(RotatingFileHandler(log_file, maxBytes=2000))
3139

3240
return _logger
3341

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pyntc"
3-
version = "2.4.1"
3+
version = "3.0.0"
44
description = "Python library focused on tasks related to device level and OS management."
55
authors = ["Network to Code, LLC <opensource@networktocode.com>"]
66
readme = "README.md"
@@ -172,7 +172,7 @@ addopts = "-vv --doctest-modules -p no:warnings --ignore-glob='*mock*'"
172172
[tool.towncrier]
173173
package = "pyntc"
174174
directory = "changes"
175-
filename = "docs/admin/release_notes/version_2.4.md"
175+
filename = "docs/admin/release_notes/version_3.0.md"
176176
template = "towncrier_template.j2"
177177
start_string = "<!-- towncrier release notes start -->"
178178
issue_format = "[#{issue}](https://github.com/networktocode/pyntc/issues/{issue})"

towncrier_template.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# v{{ versiondata.version.split(".")[:2] | join(".") }} Release Notes
32

43
This document describes all new features and changes in the release. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
@@ -8,6 +7,7 @@ This document describes all new features and changes in the release. The format
87
- Major features or milestones
98
- Changes to compatibility with Nautobot and/or other apps, libraries etc.
109

10+
<!-- towncrier release notes start -->
1111
{% if render_title %}
1212
## [v{{ versiondata.version }} ({{ versiondata.date }})](https://github.com/networktocode/pyntc/releases/tag/v{{ versiondata.version}})
1313

@@ -40,4 +40,3 @@ No significant changes.
4040

4141
{% endif %}
4242
{% endfor %}
43-

0 commit comments

Comments
 (0)