handsome-log 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2025 Pedro Dellazzari
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: handsome-log
3
+ Version: 0.1.0
4
+ Summary: Universal logger with custom levels for ETL and automation processes.
5
+ Author: Pedro Dellazzari
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.md
11
+ Requires-Dist: colorlog>=6.7.0
12
+ Dynamic: author
13
+ Dynamic: classifier
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: license-file
17
+ Dynamic: requires-dist
18
+ Dynamic: requires-python
19
+ Dynamic: summary
20
+
21
+ # handsome_log
22
+
23
+ `handsome_log` is a universal logger designed for ETL pipelines, automation tasks, and web scraping scripts in Python.
24
+
25
+ This library is built on top of Python's standard `logging` module and the excellent `colorlog` package. Full credit and gratitude go to the developers of those foundational libraries.
26
+
27
+ The main goal of `handsome_log` is to provide custom log levels that make it easier to structure and monitor all stages of your data processes. These levels help you track your pipeline with meaningful, semantically distinct messages.
28
+
29
+ By default, the following custom levels are included:
30
+
31
+ | Level | When to Use | Color |
32
+ |--------------|------------------------------------------------------|--------------|
33
+ | `STARTUP` | When initializing or starting a process | Bold Blue |
34
+ | `VALIDATION` | When validating data, schema, or credentials | Blue |
35
+ | `DRY_RUN` | For simulation runs that don't commit any changes | Purple |
36
+ | `SUCCESS` | When a process completes successfully | Bold Green |
37
+ | `INFO` | For general runtime information | Green |
38
+ | `WARNING` | When something unexpected happens, but the process continues | Yellow |
39
+ | `ERROR` | When a failure occurs but the system stays alive | Red |
40
+ | `CRITICAL` | When a critical error occurs and the process halts | Bold Red |
41
+ | `DEBUG` | For detailed technical/debugging messages | Cyan |
42
+
43
+ ---
44
+
45
+ ## Installation
46
+
47
+ Install via pip:
48
+
49
+ ```bash
50
+ pip install handsome_log
51
+ ```
52
+
53
+ ## Features
54
+ Normal logging with colors
55
+
56
+ Normal logging without colors
57
+
58
+ For loop logging
59
+
60
+ ## Usage
61
+ To import and use the library you can use:
62
+
63
+ ```bash
64
+ #import
65
+ from handsome_log import get_logger
66
+
67
+ #create logger object
68
+ logger = get_logger(__name__)
69
+
70
+ #testing different logging levels
71
+ logger.startup("Startup Script")
72
+ logger.info("General Info")
73
+ logger.validation("Validation Logging")
74
+ logger.dry_run("TEST RUN")
75
+ logger.success("Success information")
76
+ logger.warning("Warning")
77
+ logger.error("Error")
78
+ logger.critical("Critical Error")
79
+ ```
80
+
81
+ ![handsome_log_example_01](https://github.com/user-attachments/assets/dacbad77-5f89-410a-83bd-1e622f68e0ed)
82
+
83
+
@@ -0,0 +1,63 @@
1
+ # handsome_log
2
+
3
+ `handsome_log` is a universal logger designed for ETL pipelines, automation tasks, and web scraping scripts in Python.
4
+
5
+ This library is built on top of Python's standard `logging` module and the excellent `colorlog` package. Full credit and gratitude go to the developers of those foundational libraries.
6
+
7
+ The main goal of `handsome_log` is to provide custom log levels that make it easier to structure and monitor all stages of your data processes. These levels help you track your pipeline with meaningful, semantically distinct messages.
8
+
9
+ By default, the following custom levels are included:
10
+
11
+ | Level | When to Use | Color |
12
+ |--------------|------------------------------------------------------|--------------|
13
+ | `STARTUP` | When initializing or starting a process | Bold Blue |
14
+ | `VALIDATION` | When validating data, schema, or credentials | Blue |
15
+ | `DRY_RUN` | For simulation runs that don't commit any changes | Purple |
16
+ | `SUCCESS` | When a process completes successfully | Bold Green |
17
+ | `INFO` | For general runtime information | Green |
18
+ | `WARNING` | When something unexpected happens, but the process continues | Yellow |
19
+ | `ERROR` | When a failure occurs but the system stays alive | Red |
20
+ | `CRITICAL` | When a critical error occurs and the process halts | Bold Red |
21
+ | `DEBUG` | For detailed technical/debugging messages | Cyan |
22
+
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ Install via pip:
28
+
29
+ ```bash
30
+ pip install handsome_log
31
+ ```
32
+
33
+ ## Features
34
+ Normal logging with colors
35
+
36
+ Normal logging without colors
37
+
38
+ For loop logging
39
+
40
+ ## Usage
41
+ To import and use the library you can use:
42
+
43
+ ```bash
44
+ #import
45
+ from handsome_log import get_logger
46
+
47
+ #create logger object
48
+ logger = get_logger(__name__)
49
+
50
+ #testing different logging levels
51
+ logger.startup("Startup Script")
52
+ logger.info("General Info")
53
+ logger.validation("Validation Logging")
54
+ logger.dry_run("TEST RUN")
55
+ logger.success("Success information")
56
+ logger.warning("Warning")
57
+ logger.error("Error")
58
+ logger.critical("Critical Error")
59
+ ```
60
+
61
+ ![handsome_log_example_01](https://github.com/user-attachments/assets/dacbad77-5f89-410a-83bd-1e622f68e0ed)
62
+
63
+
@@ -0,0 +1 @@
1
+ from .logger import get_logger
@@ -0,0 +1,12 @@
1
+ # Cores para cada nível de log, usadas pelo colorlog
2
+ LOG_COLORS = {
3
+ "DEBUG": "cyan",
4
+ "INFO": "green",
5
+ "WARNING": "yellow",
6
+ "ERROR": "red",
7
+ "CRITICAL": "bold_red",
8
+ "SUCCESS": "bold_green",
9
+ "STARTUP": "bold_blue",
10
+ "VALIDATION": "blue",
11
+ "DRY_RUN": "purple",
12
+ }
@@ -0,0 +1,39 @@
1
+ import logging
2
+
3
+ # Custom log level values
4
+ SUCCESS_LEVEL = 25
5
+ STARTUP_LEVEL = 15
6
+ VALIDATION_LEVEL = 21
7
+ DRY_RUN_LEVEL = 16
8
+
9
+ # Register custom levels
10
+ logging.addLevelName(SUCCESS_LEVEL, "SUCCESS")
11
+ logging.addLevelName(STARTUP_LEVEL, "STARTUP")
12
+ logging.addLevelName(VALIDATION_LEVEL, "VALIDATION")
13
+ logging.addLevelName(DRY_RUN_LEVEL, "DRY_RUN")
14
+
15
+ # Custom log methods
16
+ def success(self, message, *args, **kwargs):
17
+ if self.isEnabledFor(SUCCESS_LEVEL):
18
+ self._log(SUCCESS_LEVEL, message, args, **kwargs)
19
+
20
+ def startup(self, message, *args, **kwargs):
21
+ if self.isEnabledFor(STARTUP_LEVEL):
22
+ self._log(STARTUP_LEVEL, message, args, **kwargs)
23
+
24
+ def validation(self, message, *args, **kwargs):
25
+ if self.isEnabledFor(VALIDATION_LEVEL):
26
+ self._log(VALIDATION_LEVEL, message, args, **kwargs)
27
+
28
+ def dry_run(self, message, *args, **kwargs):
29
+ if self.isEnabledFor(DRY_RUN_LEVEL):
30
+ self._log(DRY_RUN_LEVEL, message, args, **kwargs)
31
+
32
+ def register_custom_levels():
33
+ """
34
+ Binds custom logging methods to the Logger class.
35
+ """
36
+ logging.Logger.success = success
37
+ logging.Logger.startup = startup
38
+ logging.Logger.validation = validation
39
+ logging.Logger.dry_run = dry_run
@@ -0,0 +1,74 @@
1
+ import logging
2
+ import sys
3
+ from pathlib import Path
4
+ from typing import Optional
5
+
6
+ from .config import LOG_COLORS
7
+ from .levels import register_custom_levels
8
+ from .loop import loop_status
9
+
10
+ # Bind loop_status method to Logger
11
+ logging.Logger.loop_status = loop_status
12
+ register_custom_levels()
13
+
14
+
15
+ def get_logger(
16
+ name: str,
17
+ level: int = logging.DEBUG,
18
+ log_to_file: bool = False,
19
+ log_file_path: Optional[str] = None,
20
+ use_colors: bool = True,
21
+ overwrite_handlers: bool = False,
22
+ show_seconds: bool = True
23
+ ) -> logging.Logger:
24
+ """
25
+ Creates a logger with color and file output support.
26
+
27
+ Args:
28
+ name: Logger name (usually script/module name).
29
+ level: Logging level (e.g., logging.INFO).
30
+ log_to_file: If True, writes logs to a file.
31
+ log_file_path: Path to the file for log output.
32
+ use_colors: Enables ANSI color output (terminal only).
33
+ overwrite_handlers: If True, clears existing handlers.
34
+ show_seconds: Include seconds in the log timestamp.
35
+ """
36
+ logger = logging.getLogger(name)
37
+ logger.setLevel(level)
38
+
39
+ if overwrite_handlers:
40
+ logger.handlers.clear()
41
+
42
+ if not logger.handlers:
43
+ time_format = "%H:%M:%S" if show_seconds else "%H:%M"
44
+
45
+ try:
46
+ import colorlog
47
+
48
+ formatter = colorlog.ColoredFormatter(
49
+ fmt=f"%(log_color)s[%(asctime)s] [{name}] [%(levelname)s] : %(message)s",
50
+ datefmt=time_format,
51
+ log_colors=LOG_COLORS,
52
+ )
53
+ except ImportError:
54
+ formatter = logging.Formatter(
55
+ fmt=f"[%(asctime)s] [{name}] [%(levelname)s] : %(message)s",
56
+ datefmt="%Y-%m-%d %H:%M:%S",
57
+ )
58
+
59
+ console_handler = logging.StreamHandler(sys.stdout)
60
+ console_handler.setFormatter(formatter)
61
+ logger.addHandler(console_handler)
62
+
63
+ if log_to_file and log_file_path:
64
+ log_path = Path(log_file_path)
65
+ log_path.parent.mkdir(parents=True, exist_ok=True)
66
+ file_handler = logging.FileHandler(log_path, encoding="utf-8")
67
+ file_handler.setFormatter(logging.Formatter(
68
+ fmt=f"[{name}][%(asctime)s] [%(levelname)s] : %(message)s",
69
+ datefmt="%Y-%m-%d %H:%M:%S"
70
+ ))
71
+ logger.addHandler(file_handler)
72
+
73
+ logger.propagate = False
74
+ return logger
@@ -0,0 +1,67 @@
1
+ import itertools
2
+ import threading
3
+ import time
4
+ import sys
5
+ from datetime import timedelta
6
+
7
+ def loop_status(
8
+ self,
9
+ iterable,
10
+ message="Processing",
11
+ delay=0.1,
12
+ show_spinner=True,
13
+ show_percent=False,
14
+ end_message="done ✓"
15
+ ):
16
+ """
17
+ Displays a live terminal spinner while looping through an iterable.
18
+
19
+ Args:
20
+ iterable: The iterable to loop through.
21
+ message: Text to show alongside the spinner.
22
+ delay: Delay between frames (in seconds).
23
+ show_spinner: Toggle spinner display.
24
+ show_percent: Display progress as a percentage.
25
+ end_message: Message displayed after loop completion.
26
+ """
27
+ spinner = itertools.cycle(["|", "/", "-", "\\"])
28
+ stop = False
29
+ total = len(iterable) if hasattr(iterable, '__len__') else None
30
+ start_time = time.time()
31
+
32
+ def spin():
33
+ index = 0
34
+ while not stop:
35
+ spin_char = next(spinner) if show_spinner else ""
36
+ percent_text = ""
37
+ if show_percent and total:
38
+ percent = int((index / total) * 100)
39
+ percent_text = f" {percent:3d}%"
40
+ sys.stdout.write(f"\r[{self.name}] {message}{percent_text} {spin_char}")
41
+ sys.stdout.flush()
42
+ time.sleep(delay)
43
+ index += 1
44
+
45
+ elapsed = timedelta(seconds=time.time() - start_time)
46
+ elapsed_str = (
47
+ str(elapsed).split(".")[0]
48
+ if elapsed.total_seconds() > 60
49
+ else f"{elapsed.total_seconds():.2f}s"
50
+ )
51
+ sys.stdout.write(
52
+ f"\r[{self.name}] {message} {end_message} (Elapsed time: {elapsed_str})\n"
53
+ )
54
+
55
+ def wrapped():
56
+ nonlocal stop
57
+ t = threading.Thread(target=spin)
58
+ t.daemon = True
59
+ t.start()
60
+ try:
61
+ for i, item in enumerate(iterable):
62
+ yield item
63
+ finally:
64
+ stop = True
65
+ t.join()
66
+
67
+ return wrapped()
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: handsome-log
3
+ Version: 0.1.0
4
+ Summary: Universal logger with custom levels for ETL and automation processes.
5
+ Author: Pedro Dellazzari
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.md
11
+ Requires-Dist: colorlog>=6.7.0
12
+ Dynamic: author
13
+ Dynamic: classifier
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: license-file
17
+ Dynamic: requires-dist
18
+ Dynamic: requires-python
19
+ Dynamic: summary
20
+
21
+ # handsome_log
22
+
23
+ `handsome_log` is a universal logger designed for ETL pipelines, automation tasks, and web scraping scripts in Python.
24
+
25
+ This library is built on top of Python's standard `logging` module and the excellent `colorlog` package. Full credit and gratitude go to the developers of those foundational libraries.
26
+
27
+ The main goal of `handsome_log` is to provide custom log levels that make it easier to structure and monitor all stages of your data processes. These levels help you track your pipeline with meaningful, semantically distinct messages.
28
+
29
+ By default, the following custom levels are included:
30
+
31
+ | Level | When to Use | Color |
32
+ |--------------|------------------------------------------------------|--------------|
33
+ | `STARTUP` | When initializing or starting a process | Bold Blue |
34
+ | `VALIDATION` | When validating data, schema, or credentials | Blue |
35
+ | `DRY_RUN` | For simulation runs that don't commit any changes | Purple |
36
+ | `SUCCESS` | When a process completes successfully | Bold Green |
37
+ | `INFO` | For general runtime information | Green |
38
+ | `WARNING` | When something unexpected happens, but the process continues | Yellow |
39
+ | `ERROR` | When a failure occurs but the system stays alive | Red |
40
+ | `CRITICAL` | When a critical error occurs and the process halts | Bold Red |
41
+ | `DEBUG` | For detailed technical/debugging messages | Cyan |
42
+
43
+ ---
44
+
45
+ ## Installation
46
+
47
+ Install via pip:
48
+
49
+ ```bash
50
+ pip install handsome_log
51
+ ```
52
+
53
+ ## Features
54
+ Normal logging with colors
55
+
56
+ Normal logging without colors
57
+
58
+ For loop logging
59
+
60
+ ## Usage
61
+ To import and use the library you can use:
62
+
63
+ ```bash
64
+ #import
65
+ from handsome_log import get_logger
66
+
67
+ #create logger object
68
+ logger = get_logger(__name__)
69
+
70
+ #testing different logging levels
71
+ logger.startup("Startup Script")
72
+ logger.info("General Info")
73
+ logger.validation("Validation Logging")
74
+ logger.dry_run("TEST RUN")
75
+ logger.success("Success information")
76
+ logger.warning("Warning")
77
+ logger.error("Error")
78
+ logger.critical("Critical Error")
79
+ ```
80
+
81
+ ![handsome_log_example_01](https://github.com/user-attachments/assets/dacbad77-5f89-410a-83bd-1e622f68e0ed)
82
+
83
+
@@ -0,0 +1,14 @@
1
+ LICENSE.md
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ handsome_log/__init__.py
6
+ handsome_log/config.py
7
+ handsome_log/levels.py
8
+ handsome_log/logger.py
9
+ handsome_log/loop.py
10
+ handsome_log.egg-info/PKG-INFO
11
+ handsome_log.egg-info/SOURCES.txt
12
+ handsome_log.egg-info/dependency_links.txt
13
+ handsome_log.egg-info/requires.txt
14
+ handsome_log.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ colorlog>=6.7.0
@@ -0,0 +1 @@
1
+ handsome_log
@@ -0,0 +1,4 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="handsome-log",
5
+ version="0.1.0",
6
+ author="Pedro Dellazzari",
7
+ description="Universal logger with custom levels for ETL and automation processes.",
8
+ long_description=open("README.md").read(),
9
+ long_description_content_type="text/markdown",
10
+ packages=find_packages(),
11
+ install_requires=[
12
+ "colorlog>=6.7.0"
13
+ ],
14
+ classifiers=[
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ ],
18
+ python_requires='>=3.7',
19
+ )