tm-utilities 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,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: tm-utilities
3
+ Version: 0.1.0
4
+ Summary: TM Utilities
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+
8
+ # TM-Utilities
9
+
10
+ A lightweight Python logging utility that provides:
11
+
12
+ * Automatic daily log file creation
13
+ * Monthly log folder organization
14
+ * IST (Indian Standard Time) timestamps
15
+ * Console and file logging simultaneously
16
+ * Simple section separators for cleaner logs
17
+ * Minimal configuration
18
+
19
+ ## Features
20
+
21
+ ✅ Automatic log directory creation
22
+
23
+ ✅ Monthly log organization
24
+
25
+ ✅ Daily log rotation by filename
26
+
27
+ ✅ IST timezone support
28
+
29
+ ✅ Console + file logging
30
+
31
+ ✅ Configurable log levels
32
+
33
+ ✅ Section separators for structured logging
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install tm-utilities
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ```python
48
+ from tm_logger import logger
49
+
50
+ logger.info("Application started")
51
+ logger.warning("This is a warning")
52
+ logger.error("Something went wrong")
53
+ ```
54
+
55
+ ### Output
56
+
57
+ ```text
58
+ 2026-06-08 14:35:12,451 - INFO - app - main - Application started
59
+ 2026-06-08 14:35:12,452 - WARNING - app - main - This is a warning
60
+ 2026-06-08 14:35:12,453 - ERROR - app - main - Something went wrong
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Custom Logger Configuration
66
+
67
+ You can create a logger with a custom log directory and log level.
68
+
69
+ ```python
70
+ from tm_logger import setup_logger
71
+
72
+ logger = setup_logger(
73
+ log_dir="custom_logs",
74
+ debug=True
75
+ )
76
+
77
+ logger.info("Custom logger initialized")
78
+ ```
79
+
80
+ ### Parameters
81
+
82
+ | Parameter | Type | Description |
83
+ | --------- | --------------- | ------------------------------------------------------------ |
84
+ | `log_dir` | `str` or `Path` | Directory where logs will be stored |
85
+ | `debug` | `bool` | Enables DEBUG logging when `True`, INFO logging when `False` |
86
+
87
+ ---
88
+
89
+ ## Log Directory Structure
90
+
91
+ Logs are automatically organized by month and date.
92
+
93
+ ```text
94
+ logs/
95
+ └── Jun_2026/
96
+ └── 08-06-2026.log
97
+ ```
98
+
99
+ A new monthly folder is created automatically, and each day receives its own log file.
100
+
101
+ ---
102
+
103
+ ## Default Configuration
104
+
105
+ The package ships with the following defaults:
106
+
107
+ ```python
108
+ DEBUG = True
109
+ LOG_DIR = Path.cwd() / "logs"
110
+ ```
111
+
112
+ Meaning:
113
+
114
+ * Logs are stored inside a `logs/` folder in the current working directory.
115
+ * Debug logging is enabled by default.
116
+
117
+ ---
118
+
119
+ ## IST Timezone Support
120
+
121
+ All timestamps are generated in **Indian Standard Time (IST)**:
122
+
123
+ ```text
124
+ UTC +05:30
125
+ ```
126
+
127
+ This is useful for applications deployed primarily in India without requiring additional timezone configuration.
128
+
129
+ ---
130
+
131
+ ## License
132
+
133
+ MIT License
134
+
135
+ ---
136
+
137
+ ## Author
138
+
139
+ TM Utilities
140
+
141
+ Built for simple, structured Python logging with minimal setup.
@@ -0,0 +1,134 @@
1
+ # TM-Utilities
2
+
3
+ A lightweight Python logging utility that provides:
4
+
5
+ * Automatic daily log file creation
6
+ * Monthly log folder organization
7
+ * IST (Indian Standard Time) timestamps
8
+ * Console and file logging simultaneously
9
+ * Simple section separators for cleaner logs
10
+ * Minimal configuration
11
+
12
+ ## Features
13
+
14
+ ✅ Automatic log directory creation
15
+
16
+ ✅ Monthly log organization
17
+
18
+ ✅ Daily log rotation by filename
19
+
20
+ ✅ IST timezone support
21
+
22
+ ✅ Console + file logging
23
+
24
+ ✅ Configurable log levels
25
+
26
+ ✅ Section separators for structured logging
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install tm-utilities
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Quick Start
39
+
40
+ ```python
41
+ from tm_logger import logger
42
+
43
+ logger.info("Application started")
44
+ logger.warning("This is a warning")
45
+ logger.error("Something went wrong")
46
+ ```
47
+
48
+ ### Output
49
+
50
+ ```text
51
+ 2026-06-08 14:35:12,451 - INFO - app - main - Application started
52
+ 2026-06-08 14:35:12,452 - WARNING - app - main - This is a warning
53
+ 2026-06-08 14:35:12,453 - ERROR - app - main - Something went wrong
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Custom Logger Configuration
59
+
60
+ You can create a logger with a custom log directory and log level.
61
+
62
+ ```python
63
+ from tm_logger import setup_logger
64
+
65
+ logger = setup_logger(
66
+ log_dir="custom_logs",
67
+ debug=True
68
+ )
69
+
70
+ logger.info("Custom logger initialized")
71
+ ```
72
+
73
+ ### Parameters
74
+
75
+ | Parameter | Type | Description |
76
+ | --------- | --------------- | ------------------------------------------------------------ |
77
+ | `log_dir` | `str` or `Path` | Directory where logs will be stored |
78
+ | `debug` | `bool` | Enables DEBUG logging when `True`, INFO logging when `False` |
79
+
80
+ ---
81
+
82
+ ## Log Directory Structure
83
+
84
+ Logs are automatically organized by month and date.
85
+
86
+ ```text
87
+ logs/
88
+ └── Jun_2026/
89
+ └── 08-06-2026.log
90
+ ```
91
+
92
+ A new monthly folder is created automatically, and each day receives its own log file.
93
+
94
+ ---
95
+
96
+ ## Default Configuration
97
+
98
+ The package ships with the following defaults:
99
+
100
+ ```python
101
+ DEBUG = True
102
+ LOG_DIR = Path.cwd() / "logs"
103
+ ```
104
+
105
+ Meaning:
106
+
107
+ * Logs are stored inside a `logs/` folder in the current working directory.
108
+ * Debug logging is enabled by default.
109
+
110
+ ---
111
+
112
+ ## IST Timezone Support
113
+
114
+ All timestamps are generated in **Indian Standard Time (IST)**:
115
+
116
+ ```text
117
+ UTC +05:30
118
+ ```
119
+
120
+ This is useful for applications deployed primarily in India without requiring additional timezone configuration.
121
+
122
+ ---
123
+
124
+ ## License
125
+
126
+ MIT License
127
+
128
+ ---
129
+
130
+ ## Author
131
+
132
+ TM Utilities
133
+
134
+ Built for simple, structured Python logging with minimal setup.
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tm-utilities"
7
+ version = "0.1.0"
8
+ description = "TM Utilities"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+
12
+ [tool.setuptools]
13
+ package-dir = {"" = "src"}
14
+
15
+ [tool.setuptools.packages.find]
16
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .logger import logger
2
+
3
+ __all__ = ["logger"]
@@ -0,0 +1,76 @@
1
+ import logging
2
+ from pathlib import Path
3
+ from datetime import datetime, timedelta, timezone
4
+
5
+
6
+ # Default settings
7
+ DEBUG = True
8
+ LOG_DIR = Path.cwd() / "logs"
9
+
10
+
11
+ # Function to create IST timezone
12
+ def ist_time(*args):
13
+ ist = timezone(timedelta(hours=5, minutes=30))
14
+ return datetime.now(ist).timetuple()
15
+
16
+
17
+ def log_separator(section_name=None, char="*", line_length=50, spacer_lines=2):
18
+ blank_line = " "
19
+ separator_line = char * line_length
20
+
21
+ for _ in range(spacer_lines):
22
+ logger.info(blank_line)
23
+
24
+ logger.info(separator_line)
25
+
26
+ if section_name:
27
+ logger.info(f"{section_name.center(line_length)}")
28
+ logger.info(separator_line)
29
+
30
+ for _ in range(spacer_lines):
31
+ logger.info(blank_line)
32
+
33
+
34
+ def setup_logger(log_dir=None, debug=None):
35
+
36
+ log_dir = Path(log_dir) if log_dir else LOG_DIR
37
+ debug = DEBUG if debug is None else debug
38
+
39
+ # Create logs directory
40
+ log_dir.mkdir(parents=True, exist_ok=True)
41
+
42
+ # Create monthly folder
43
+ month_folder = datetime.now().strftime("%b_%Y")
44
+ month_path = log_dir / month_folder
45
+ month_path.mkdir(parents=True, exist_ok=True)
46
+
47
+ # Daily log file
48
+ log_file = month_path / f"{datetime.now().strftime('%d-%m-%Y')}.log"
49
+
50
+ log_level = logging.DEBUG if debug else logging.INFO
51
+
52
+ logger = logging.getLogger("tm_logs")
53
+ logger.setLevel(log_level)
54
+
55
+ # Prevent duplicate handlers
56
+ if not logger.handlers:
57
+
58
+ file_handler = logging.FileHandler(log_file, mode="a")
59
+ console_handler = logging.StreamHandler()
60
+
61
+ formatter = logging.Formatter(
62
+ "%(asctime)s - %(levelname)s - %(module)s - %(funcName)s - %(message)s"
63
+ )
64
+ formatter.converter = ist_time
65
+
66
+ file_handler.setFormatter(formatter)
67
+ console_handler.setFormatter(formatter)
68
+
69
+ logger.addHandler(file_handler)
70
+ logger.addHandler(console_handler)
71
+
72
+ return logger
73
+
74
+
75
+ # Default logger
76
+ logger = setup_logger()
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: tm-utilities
3
+ Version: 0.1.0
4
+ Summary: TM Utilities
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+
8
+ # TM-Utilities
9
+
10
+ A lightweight Python logging utility that provides:
11
+
12
+ * Automatic daily log file creation
13
+ * Monthly log folder organization
14
+ * IST (Indian Standard Time) timestamps
15
+ * Console and file logging simultaneously
16
+ * Simple section separators for cleaner logs
17
+ * Minimal configuration
18
+
19
+ ## Features
20
+
21
+ ✅ Automatic log directory creation
22
+
23
+ ✅ Monthly log organization
24
+
25
+ ✅ Daily log rotation by filename
26
+
27
+ ✅ IST timezone support
28
+
29
+ ✅ Console + file logging
30
+
31
+ ✅ Configurable log levels
32
+
33
+ ✅ Section separators for structured logging
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install tm-utilities
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ```python
48
+ from tm_logger import logger
49
+
50
+ logger.info("Application started")
51
+ logger.warning("This is a warning")
52
+ logger.error("Something went wrong")
53
+ ```
54
+
55
+ ### Output
56
+
57
+ ```text
58
+ 2026-06-08 14:35:12,451 - INFO - app - main - Application started
59
+ 2026-06-08 14:35:12,452 - WARNING - app - main - This is a warning
60
+ 2026-06-08 14:35:12,453 - ERROR - app - main - Something went wrong
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Custom Logger Configuration
66
+
67
+ You can create a logger with a custom log directory and log level.
68
+
69
+ ```python
70
+ from tm_logger import setup_logger
71
+
72
+ logger = setup_logger(
73
+ log_dir="custom_logs",
74
+ debug=True
75
+ )
76
+
77
+ logger.info("Custom logger initialized")
78
+ ```
79
+
80
+ ### Parameters
81
+
82
+ | Parameter | Type | Description |
83
+ | --------- | --------------- | ------------------------------------------------------------ |
84
+ | `log_dir` | `str` or `Path` | Directory where logs will be stored |
85
+ | `debug` | `bool` | Enables DEBUG logging when `True`, INFO logging when `False` |
86
+
87
+ ---
88
+
89
+ ## Log Directory Structure
90
+
91
+ Logs are automatically organized by month and date.
92
+
93
+ ```text
94
+ logs/
95
+ └── Jun_2026/
96
+ └── 08-06-2026.log
97
+ ```
98
+
99
+ A new monthly folder is created automatically, and each day receives its own log file.
100
+
101
+ ---
102
+
103
+ ## Default Configuration
104
+
105
+ The package ships with the following defaults:
106
+
107
+ ```python
108
+ DEBUG = True
109
+ LOG_DIR = Path.cwd() / "logs"
110
+ ```
111
+
112
+ Meaning:
113
+
114
+ * Logs are stored inside a `logs/` folder in the current working directory.
115
+ * Debug logging is enabled by default.
116
+
117
+ ---
118
+
119
+ ## IST Timezone Support
120
+
121
+ All timestamps are generated in **Indian Standard Time (IST)**:
122
+
123
+ ```text
124
+ UTC +05:30
125
+ ```
126
+
127
+ This is useful for applications deployed primarily in India without requiring additional timezone configuration.
128
+
129
+ ---
130
+
131
+ ## License
132
+
133
+ MIT License
134
+
135
+ ---
136
+
137
+ ## Author
138
+
139
+ TM Utilities
140
+
141
+ Built for simple, structured Python logging with minimal setup.
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/tm_logger/__init__.py
4
+ src/tm_logger/logger.py
5
+ src/tm_utilities.egg-info/PKG-INFO
6
+ src/tm_utilities.egg-info/SOURCES.txt
7
+ src/tm_utilities.egg-info/dependency_links.txt
8
+ src/tm_utilities.egg-info/top_level.txt
9
+ tests/test_logger.py
@@ -0,0 +1,5 @@
1
+ from tm_logger.logger import setup_logger
2
+
3
+ def test_logger_creation():
4
+ logger = setup_logger()
5
+ assert logger is not None