THCustomLogger 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.
- thcustomlogger-0.1.0/.idea/.gitignore +15 -0
- thcustomlogger-0.1.0/.idea/CustomLogger.iml +13 -0
- thcustomlogger-0.1.0/.idea/inspectionProfiles/Project_Default.xml +35 -0
- thcustomlogger-0.1.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- thcustomlogger-0.1.0/.idea/misc.xml +6 -0
- thcustomlogger-0.1.0/.idea/modules.xml +8 -0
- thcustomlogger-0.1.0/.idea/vcs.xml +6 -0
- thcustomlogger-0.1.0/.idea/workspace.xml +117 -0
- thcustomlogger-0.1.0/LICENSE +21 -0
- thcustomlogger-0.1.0/PKG-INFO +20 -0
- thcustomlogger-0.1.0/README.md +5 -0
- thcustomlogger-0.1.0/pyproject.toml +25 -0
- thcustomlogger-0.1.0/requirements.txt +2 -0
- thcustomlogger-0.1.0/src/THCustomLogger/__init__.py +0 -0
- thcustomlogger-0.1.0/src/THCustomLogger/logger_setup.py +139 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Default ignored files
|
|
2
|
+
/shelf/
|
|
3
|
+
/workspace.xml
|
|
4
|
+
# Editor-based HTTP Client requests
|
|
5
|
+
/httpRequests/
|
|
6
|
+
# Datasource local storage ignored files
|
|
7
|
+
/dataSources/
|
|
8
|
+
/dataSources.local.xml
|
|
9
|
+
/.gitignore
|
|
10
|
+
/CustomLogger.iml
|
|
11
|
+
/misc.xml
|
|
12
|
+
/modules.xml
|
|
13
|
+
/inspectionProfiles/profiles_settings.xml
|
|
14
|
+
/inspectionProfiles/Project_Default.xml
|
|
15
|
+
/vcs.xml
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
|
6
|
+
</content>
|
|
7
|
+
<orderEntry type="jdk" jdkName="Python 3.13 (CustomLogger)" jdkType="Python SDK" />
|
|
8
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
9
|
+
</component>
|
|
10
|
+
<component name="PackageRequirementsSettings">
|
|
11
|
+
<option name="keepMatchingSpecifier" value="false" />
|
|
12
|
+
</component>
|
|
13
|
+
</module>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
|
2
|
+
<profile version="1.0">
|
|
3
|
+
<option name="myName" value="Project Default" />
|
|
4
|
+
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
5
|
+
<Languages>
|
|
6
|
+
<language minSize="55" name="Python" />
|
|
7
|
+
</Languages>
|
|
8
|
+
</inspection_tool>
|
|
9
|
+
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
|
10
|
+
<option name="ignoredPackages">
|
|
11
|
+
<value>
|
|
12
|
+
<list size="6">
|
|
13
|
+
<item index="0" class="java.lang.String" itemvalue="adafruit-blinka" />
|
|
14
|
+
<item index="1" class="java.lang.String" itemvalue="matplotlib" />
|
|
15
|
+
<item index="2" class="java.lang.String" itemvalue="SQLAlchemy" />
|
|
16
|
+
<item index="3" class="java.lang.String" itemvalue="board" />
|
|
17
|
+
<item index="4" class="java.lang.String" itemvalue="requests" />
|
|
18
|
+
<item index="5" class="java.lang.String" itemvalue="pytz" />
|
|
19
|
+
</list>
|
|
20
|
+
</value>
|
|
21
|
+
</option>
|
|
22
|
+
</inspection_tool>
|
|
23
|
+
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
24
|
+
<option name="ignoredErrors">
|
|
25
|
+
<list>
|
|
26
|
+
<option value="N806" />
|
|
27
|
+
<option value="N803" />
|
|
28
|
+
</list>
|
|
29
|
+
</option>
|
|
30
|
+
</inspection_tool>
|
|
31
|
+
<inspection_tool class="PyTypeCheckerInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
32
|
+
<inspection_tool class="SqlDialectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
33
|
+
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
34
|
+
</profile>
|
|
35
|
+
</component>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/CustomLogger.iml" filepath="$PROJECT_DIR$/.idea/CustomLogger.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="AutoImportSettings">
|
|
4
|
+
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ChangeListManager">
|
|
7
|
+
<list default="true" id="9f76e348-4220-4d67-b63b-d36f23fd8850" name="Changes" comment="Add initial implementation of custom logging package This commit introduces a custom logging package with multiline and colored formatting. It includes setup scripts (`setup.py`, `pyproject.toml`), dependency management files (`requirements.txt`), and logging setup with support for git metadata retrieval. The package provides advanced logging capabilities for enhanced debugging and readability.">
|
|
8
|
+
<change afterPath="$PROJECT_DIR$/LICENSE" afterDir="false" />
|
|
9
|
+
<change afterPath="$PROJECT_DIR$/src/THCustomLogger/__init__.py" afterDir="false" />
|
|
10
|
+
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
|
11
|
+
<change beforePath="$PROJECT_DIR$/pyproject.toml" beforeDir="false" afterPath="$PROJECT_DIR$/pyproject.toml" afterDir="false" />
|
|
12
|
+
<change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" />
|
|
13
|
+
<change beforePath="$PROJECT_DIR$/src/__init__.py" beforeDir="false" />
|
|
14
|
+
<change beforePath="$PROJECT_DIR$/src/logger_setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/THCustomLogger/logger_setup.py" afterDir="false" />
|
|
15
|
+
</list>
|
|
16
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
17
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
18
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
19
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
20
|
+
</component>
|
|
21
|
+
<component name="FileTemplateManagerImpl">
|
|
22
|
+
<option name="RECENT_TEMPLATES">
|
|
23
|
+
<list>
|
|
24
|
+
<option value="Python Script" />
|
|
25
|
+
</list>
|
|
26
|
+
</option>
|
|
27
|
+
</component>
|
|
28
|
+
<component name="Git.Settings">
|
|
29
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
30
|
+
</component>
|
|
31
|
+
<component name="GitHubPullRequestSearchHistory">{
|
|
32
|
+
"lastFilter": {
|
|
33
|
+
"state": "OPEN",
|
|
34
|
+
"assignee": "TabgoHotel"
|
|
35
|
+
}
|
|
36
|
+
}</component>
|
|
37
|
+
<component name="GithubPullRequestsUISettings">{
|
|
38
|
+
"selectedUrlAndAccountId": {
|
|
39
|
+
"url": "https://github.com/TabgoHotel/CustomLogger.git",
|
|
40
|
+
"accountId": "ba1fa2a0-f1fb-4751-9c86-b5245a520836"
|
|
41
|
+
}
|
|
42
|
+
}</component>
|
|
43
|
+
<component name="ProjectColorInfo">{
|
|
44
|
+
"associatedIndex": 1
|
|
45
|
+
}</component>
|
|
46
|
+
<component name="ProjectId" id="2vYvlQhzj4XA6x2qyeH8ZIx3mQ8" />
|
|
47
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
48
|
+
<component name="ProjectViewState">
|
|
49
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
50
|
+
<option name="showLibraryContents" value="true" />
|
|
51
|
+
</component>
|
|
52
|
+
<component name="PropertiesComponent">{
|
|
53
|
+
"keyToString": {
|
|
54
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
55
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
56
|
+
"git-widget-placeholder": "main",
|
|
57
|
+
"node.js.detected.package.eslint": "true",
|
|
58
|
+
"node.js.detected.package.tslint": "true",
|
|
59
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
60
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
61
|
+
"nodejs_package_manager_path": "npm",
|
|
62
|
+
"settings.editor.selected.configurable": "configurable.group.appearance",
|
|
63
|
+
"vue.rearranger.settings.migration": "true"
|
|
64
|
+
}
|
|
65
|
+
}</component>
|
|
66
|
+
<component name="RecentsManager">
|
|
67
|
+
<key name="MoveFile.RECENT_KEYS">
|
|
68
|
+
<recent name="$PROJECT_DIR$/src/customlogger" />
|
|
69
|
+
</key>
|
|
70
|
+
</component>
|
|
71
|
+
<component name="SharedIndexes">
|
|
72
|
+
<attachedChunks>
|
|
73
|
+
<set>
|
|
74
|
+
<option value="bundled-js-predefined-d6986cc7102b-1632447f56bf-JavaScript-PY-243.26053.29" />
|
|
75
|
+
<option value="bundled-python-sdk-b1dbf8ef85a6-4df51de95216-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-243.26053.29" />
|
|
76
|
+
</set>
|
|
77
|
+
</attachedChunks>
|
|
78
|
+
</component>
|
|
79
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
80
|
+
<component name="TaskManager">
|
|
81
|
+
<task active="true" id="Default" summary="Default task">
|
|
82
|
+
<changelist id="9f76e348-4220-4d67-b63b-d36f23fd8850" name="Changes" comment="" />
|
|
83
|
+
<created>1744334972790</created>
|
|
84
|
+
<option name="number" value="Default" />
|
|
85
|
+
<option name="presentableId" value="Default" />
|
|
86
|
+
<updated>1744334972790</updated>
|
|
87
|
+
<workItem from="1744334973837" duration="2400000" />
|
|
88
|
+
<workItem from="1744337383264" duration="272000" />
|
|
89
|
+
<workItem from="1744501665438" duration="3734000" />
|
|
90
|
+
</task>
|
|
91
|
+
<task id="LOCAL-00001" summary="Add initial implementation of custom logging package This commit introduces a custom logging package with multiline and colored formatting. It includes setup scripts (`setup.py`, `pyproject.toml`), dependency management files (`requirements.txt`), and logging setup with support for git metadata retrieval. The package provides advanced logging capabilities for enhanced debugging and readability.">
|
|
92
|
+
<option name="closed" value="true" />
|
|
93
|
+
<created>1744336022654</created>
|
|
94
|
+
<option name="number" value="00001" />
|
|
95
|
+
<option name="presentableId" value="LOCAL-00001" />
|
|
96
|
+
<option name="project" value="LOCAL" />
|
|
97
|
+
<updated>1744336022654</updated>
|
|
98
|
+
</task>
|
|
99
|
+
<task id="LOCAL-00002" summary="Add initial implementation of custom logging package This commit introduces a custom logging package with multiline and colored formatting. It includes setup scripts (`setup.py`, `pyproject.toml`), dependency management files (`requirements.txt`), and logging setup with support for git metadata retrieval. The package provides advanced logging capabilities for enhanced debugging and readability.">
|
|
100
|
+
<option name="closed" value="true" />
|
|
101
|
+
<created>1744337203524</created>
|
|
102
|
+
<option name="number" value="00002" />
|
|
103
|
+
<option name="presentableId" value="LOCAL-00002" />
|
|
104
|
+
<option name="project" value="LOCAL" />
|
|
105
|
+
<updated>1744337203524</updated>
|
|
106
|
+
</task>
|
|
107
|
+
<option name="localTasksCounter" value="3" />
|
|
108
|
+
<servers />
|
|
109
|
+
</component>
|
|
110
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
111
|
+
<option name="version" value="3" />
|
|
112
|
+
</component>
|
|
113
|
+
<component name="VcsManagerConfiguration">
|
|
114
|
+
<MESSAGE value="Add initial implementation of custom logging package This commit introduces a custom logging package with multiline and colored formatting. It includes setup scripts (`setup.py`, `pyproject.toml`), dependency management files (`requirements.txt`), and logging setup with support for git metadata retrieval. The package provides advanced logging capabilities for enhanced debugging and readability." />
|
|
115
|
+
<option name="LAST_COMMIT_MESSAGE" value="Add initial implementation of custom logging package This commit introduces a custom logging package with multiline and colored formatting. It includes setup scripts (`setup.py`, `pyproject.toml`), dependency management files (`requirements.txt`), and logging setup with support for git metadata retrieval. The package provides advanced logging capabilities for enhanced debugging and readability." />
|
|
116
|
+
</component>
|
|
117
|
+
</project>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tyler Haunreiter
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: THCustomLogger
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A custom logging package with multiline formatting
|
|
5
|
+
Project-URL: Homepage, https://github.com/TabgoHotel/CustomLogger.git
|
|
6
|
+
Author-email: Tyler Haunreiter <silentbox23@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: colorlog
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# custom_logger
|
|
17
|
+
|
|
18
|
+
A simple, reusable logger setup to use across projects.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "THCustomLogger"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A custom logging package with multiline formatting"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Tyler Haunreiter", email = "silentbox23@gmail.com"},
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"colorlog"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["hatchling"]
|
|
22
|
+
build-backend = "hatchling.build"
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
"Homepage" = "https://github.com/TabgoHotel/CustomLogger.git"
|
|
File without changes
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import colorlog
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def setup_logger():
|
|
11
|
+
log_dir = Path(__file__).parent
|
|
12
|
+
if 'src' in log_dir.name:
|
|
13
|
+
log_dir = log_dir.parent
|
|
14
|
+
log_dir = os.path.join(log_dir, 'logs')
|
|
15
|
+
|
|
16
|
+
os.makedirs(log_dir, exist_ok=True)
|
|
17
|
+
|
|
18
|
+
log_file = os.path.join(log_dir, 'log.txt')
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
log.setLevel(logging.DEBUG)
|
|
22
|
+
|
|
23
|
+
if log.hasHandlers():
|
|
24
|
+
log.handlers.clear()
|
|
25
|
+
|
|
26
|
+
# Formatting
|
|
27
|
+
msg_fmt = "%(asctime)s.%(msecs)03d | Line: %(lineno)3d %(module)s.%(funcName)-20s | %(levelname)-8s: %(message)s"
|
|
28
|
+
date_fmt = "%Y-%m-%d %H:%M:%S"
|
|
29
|
+
|
|
30
|
+
file_formatter = MultilineFormatter(fmt=msg_fmt, datefmt=date_fmt)
|
|
31
|
+
file_handler = logging.FileHandler(log_file)
|
|
32
|
+
file_handler.setFormatter(file_formatter)
|
|
33
|
+
log.addHandler(file_handler)
|
|
34
|
+
|
|
35
|
+
console_formatter = ColoredMultilineFormatter(
|
|
36
|
+
"%(log_color)s" + msg_fmt,
|
|
37
|
+
datefmt=date_fmt,
|
|
38
|
+
log_colors={
|
|
39
|
+
'DEBUG': 'green',
|
|
40
|
+
'INFO': 'light_white',
|
|
41
|
+
'WARNING': 'light_yellow',
|
|
42
|
+
'ERROR': 'light_red',
|
|
43
|
+
'CRITICAL': 'bold_light_red',
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
console_handler = logging.StreamHandler(sys.stdout)
|
|
47
|
+
console_handler.setFormatter(console_formatter)
|
|
48
|
+
log.addHandler(console_handler)
|
|
49
|
+
|
|
50
|
+
return log
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_commit_hash():
|
|
54
|
+
try:
|
|
55
|
+
commit_hash = subprocess.check_output(
|
|
56
|
+
["git", "rev-parse", "HEAD"], stderr=subprocess.STDOUT
|
|
57
|
+
).decode("utf-8").strip()
|
|
58
|
+
return commit_hash
|
|
59
|
+
except subprocess.CalledProcessError as e:
|
|
60
|
+
logger.error(f"Error getting commit hash: {e.output.decode('utf-8')}")
|
|
61
|
+
return "unknown"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_latest_tag():
|
|
65
|
+
try:
|
|
66
|
+
latest_tag = subprocess.check_output(
|
|
67
|
+
["git", "describe", "--tags", "--abbrev=0"], stderr=subprocess.STDOUT
|
|
68
|
+
).decode("utf-8").strip()
|
|
69
|
+
return latest_tag
|
|
70
|
+
except subprocess.CalledProcessError as e:
|
|
71
|
+
logger.error(f"Error getting latest tag: {e.output.decode('utf-8')}")
|
|
72
|
+
return "unknown"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class MultilineFormatter(logging.Formatter):
|
|
76
|
+
def format(self, record):
|
|
77
|
+
original = super().format(record)
|
|
78
|
+
message = record.getMessage()
|
|
79
|
+
prefix, _, _ = original.partition(message)
|
|
80
|
+
return _format_multiline(record, original, message, prefix)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ColoredMultilineFormatter(colorlog.ColoredFormatter):
|
|
84
|
+
def format(self, record):
|
|
85
|
+
original = super().format(record)
|
|
86
|
+
message = record.getMessage()
|
|
87
|
+
prefix, _, _ = original.partition(message)
|
|
88
|
+
return _format_multiline(record, original, message, prefix, color_offset=5)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _format_multiline(record, original, message, prefix, color_offset=0):
|
|
92
|
+
indent = ' ' * (len(prefix) - color_offset)
|
|
93
|
+
|
|
94
|
+
msg_break = getattr(record, 'msg_break', None)
|
|
95
|
+
if msg_break is not None:
|
|
96
|
+
msg_break = msg_break * (len(prefix) - color_offset)
|
|
97
|
+
|
|
98
|
+
no_indent = getattr(record, 'no_indent', False)
|
|
99
|
+
if no_indent or '\n' not in message:
|
|
100
|
+
if msg_break is not None:
|
|
101
|
+
return original + '\n' + msg_break
|
|
102
|
+
return original
|
|
103
|
+
|
|
104
|
+
if '\n' in message:
|
|
105
|
+
lines = message.splitlines()
|
|
106
|
+
indented_message = lines[0] + '\n' + '\n'.join(indent + line for line in lines[1:])
|
|
107
|
+
formatted = prefix + indented_message
|
|
108
|
+
|
|
109
|
+
if msg_break is not None:
|
|
110
|
+
return formatted + '\n' + msg_break
|
|
111
|
+
return formatted
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
logger = setup_logger()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def main():
|
|
118
|
+
logger.info(f"Done.", extra={'msg_break': '*'})
|
|
119
|
+
logger.info(f"Done.\n----------", extra={'no_indent': True})
|
|
120
|
+
logger.info(f"Done.\nfffffffffff", extra={'msg_break': '/', 'no_indent': True})
|
|
121
|
+
|
|
122
|
+
logger.debug('debug message')
|
|
123
|
+
logger.info('hello world')
|
|
124
|
+
logger.warning('Oh No')
|
|
125
|
+
logger.error('Error')
|
|
126
|
+
logger.critical('Critical')
|
|
127
|
+
logger.info(f"Commit hash: {get_commit_hash()}\nLatest tag:")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def example():
|
|
131
|
+
try:
|
|
132
|
+
1 / 0
|
|
133
|
+
except Exception as e:
|
|
134
|
+
logger.exception(e)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if __name__ == "__main__":
|
|
138
|
+
main()
|
|
139
|
+
example()
|