Commit 12c3db4
authored
Add bootstrap logging, path preparation helpers, and broader tooling/documentation improvements (#5)
* feat: add bootstrap logging workflow and refresh package docs
Introduce runtime bootstrap logging with start_file_logger() and stop_file_logger() so early startup records can be buffered, stdout/stderr can be captured, and buffered messages can be flushed once configure_logger() installs the final handlers.
Expose the new bootstrap logging helpers through the public API, update console handler creation to support explicit streams, flush buffered records during logger configuration, and harden config loading by importing YAML support lazily so environments without PyYAML fail through the shared error policy instead of at module import time.
Refine typing and packaging details by adding overloads for handle_error(), marking the PyYAML import for type checking, expanding pyproject metadata and optional dev dependencies, splitting runtime and development requirements, adding pytest discovery settings, and broadening .gitignore coverage for Python, tooling, editor, and OS artifacts.
Rework the test suite around pytest fixtures and temporary cache directories, remove the old bootstrap/path helpers, simplify test modules into direct function-based tests, and extend logger coverage to verify buffered bootstrap records plus stdout/stderr capture behavior alongside the existing file, config, masking, and serialization checks.
Rewrite the README and large parts of the documentation to better onboard new users, clarify the library's purpose, document the error-handling and logging concepts in more depth, expand the tool pages with practical examples and usage guidance, and add dedicated reference pages for start_file_logger() and stop_file_logger().
This commit is still a broad work-in-progress snapshot. The new logging flow and the larger documentation/testing refresh are in place, but the state should continue to be validated and may still receive follow-up adjustments, cleanup, and refinement.
* feat: add path preparation helpers for files and directories
Introduce ensure_file() and ensure_dir() as new public helpers for preparing filesystem targets before later reads, writes, logging, cache generation, or export steps. The new path utility module normalizes single-path and multi-path inputs, creates missing parent directories as needed, and routes validation or filesystem failures through the shared clevertools error policy.
Expose the new helpers through the package root API so they can be imported directly from clevertools, and document them in the main README plus the tools index to make the expanded filesystem helper surface easier to discover.
Add dedicated documentation pages for ensure_file() and ensure_dir() with signatures, behavior notes, and practical examples covering single paths, multiple paths, nested directory preparation, replacement content, and binary file initialization.
Extend the test suite with focused coverage for the new path utilities, including creation of missing files and directories, list input support, content replacement behavior, binary payload handling, preservation of existing files by default, and validation failures for wrong target types or invalid path inputs.
This snapshot appears to be a smaller incremental feature update rather than a large refactor, but it is still a work in progress and may receive follow-up cleanup, polish, or additional validation in later commits.
* fix: harden bootstrap logging and path helper error handling
Prevent duplicated bootstrap console output when stdout or stderr capture is enabled and the final logger configuration also writes to the console.
Update the runtime bootstrap flow to keep explicit stream redirect objects, flush buffered partial output before restoring the original streams, and ensure early startup messages are emitted exactly once through the configured logger handlers.
Align ensure_file() and ensure_dir() with the package-wide error policy by restoring None-based on_error defaults so configured global error handling is respected automatically.
Clean up path helper validation messages so conflicting file and directory targets report the concrete path value instead of a literal placeholder.
Expand logger regression coverage with a dedicated test that verifies captured bootstrap stdout and stderr do not appear twice on the console while still being persisted to the log file.
* fix: tighten logger formatter behavior and coverage
Make the datetime logging preset honor custom date_format values instead of always rendering the built-in default date layout.
Route console color detection through the actual handler stream so ANSI coloring follows the real output target rather than relying on sys.stdout.
Pass the console handler stream into CleverToolsFormatter and keep the formatter logic aligned with the configured logger output path.
Expand logger regression coverage with focused tests for custom datetime formatting and stream-aware color handling, alongside the earlier bootstrap logging protections.
This keeps the logger API behavior consistent with its configuration surface while preserving clean test and mypy results in the project venv.1 parent e20e5ef commit 12c3db4
61 files changed
Lines changed: 2315 additions & 636 deletions
File tree
- docs
- concepts
- tools
- src/clevertools
- errors
- file
- logger
- system
- tests
- tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
5 | 49 | | |
6 | 50 | | |
7 | 51 | | |
| |||
14 | 58 | | |
15 | 59 | | |
16 | 60 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
36 | 65 | | |
37 | 66 | | |
38 | 67 | | |
| 68 | + | |
39 | 69 | | |
40 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
41 | 74 | | |
42 | 75 | | |
43 | 76 | | |
44 | 77 | | |
45 | 78 | | |
46 | 79 | | |
47 | 80 | | |
| 81 | + | |
48 | 82 | | |
| 83 | + | |
49 | 84 | | |
50 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 7 | + | |
13 | 8 | | |
14 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
15 | 47 | | |
16 | 48 | | |
17 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
18 | 57 | | |
19 | 58 | | |
20 | 59 | | |
21 | 60 | | |
22 | 61 | | |
| 62 | + | |
23 | 63 | | |
24 | 64 | | |
25 | 65 | | |
26 | 66 | | |
27 | | - | |
| 67 | + | |
28 | 68 | | |
29 | 69 | | |
30 | 70 | | |
31 | 71 | | |
| 72 | + | |
32 | 73 | | |
33 | 74 | | |
34 | | - | |
| 75 | + | |
35 | 76 | | |
36 | 77 | | |
37 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
38 | 82 | | |
39 | 83 | | |
40 | | - | |
| 84 | + | |
41 | 85 | | |
42 | | - | |
| 86 | + | |
43 | 87 | | |
44 | | - | |
| 88 | + | |
| 89 | + | |
45 | 90 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
49 | 94 | | |
50 | | - | |
| 95 | + | |
51 | 96 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 97 | + | |
| 98 | + | |
61 | 99 | | |
62 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
63 | 160 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
71 | 166 | | |
72 | | - | |
| 167 | + | |
73 | 168 | | |
74 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
75 | 173 | | |
76 | | - | |
| 174 | + | |
77 | 175 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
85 | 180 | | |
86 | 181 | | |
87 | 182 | | |
88 | 183 | | |
89 | 184 | | |
90 | 185 | | |
91 | 186 | | |
92 | | - | |
| 187 | + | |
93 | 188 | | |
94 | 189 | | |
95 | 190 | | |
| |||
0 commit comments