From 0b5fa2c90ec6ff2968002c47683c71f0c40dabe7 Mon Sep 17 00:00:00 2001 From: uysalserkan Date: Tue, 22 Oct 2024 20:56:17 +0300 Subject: [PATCH 1/2] Remove PDF topic. --- pyproject.toml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6c8f958..8509a64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,6 @@ classifiers = [ "Topic :: System :: Logging", "Topic :: Text Processing :: Markup", "Topic :: Text Processing :: Markup :: Markdown", - "Topic :: Text Processing :: Markup :: PDF", "Topic :: Utilities", ] @@ -46,19 +45,3 @@ click = "^8.0.4" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" - -#build-backend = "setuptools.build_meta" - -#[project] -#name = "Logges" -#requires-python = ">=3.6" -#version = "2.2" -# -#[build-system] -#requires = [ -# "setuptools", -# 'matplotlib==3.5.2', -# 'rich==10.16.2', -# 'reportlab==3.5.67', -# 'click==8.0.4', -#] From e0101b1fb1363f4361bffb3e881122bc8accfebe Mon Sep 17 00:00:00 2001 From: uysalserkan Date: Thu, 24 Oct 2024 18:34:01 +0300 Subject: [PATCH 2/2] Add default print status. --- pyproject.toml | 2 +- src/Logges/logges.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8509a64..ae71a7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "Logges" -version = "2.2.1" +version = "2.2.2" description = "A simple Logging tool can extract as Markdown, PDF, or print console." authors = ["Serkan UYSAL", "Ozkan UYSAL"] maintainers = ["Serkan UYSAL "] diff --git a/src/Logges/logges.py b/src/Logges/logges.py index 8431957..2b27685 100644 --- a/src/Logges/logges.py +++ b/src/Logges/logges.py @@ -7,6 +7,7 @@ """ import os import sys +from ast import literal_eval from enum import Enum from shutil import copy2 from typing import Dict @@ -77,7 +78,8 @@ def get_icon_dict() -> Dict[str, str]: @staticmethod def setup(logname: str = None, - status_level: LogStatus = LogStatus.ERROR) -> None: + status_level: LogStatus = LogStatus.ERROR, + print_status: bool = True) -> None: """Set the environment. Set up environment and setting the logfile name. @@ -87,10 +89,13 @@ def setup(logname: str = None, logname `str`: It defines your log file name. status_level `LogStatus`: If status equal or greater than parameter, automatically print it. Default value is `LogStatus.ERROR` + print_status `bool`: Show on console log status. Return: None """ + + os.environ["print_status"] = str(print_status) global FILENAME, SAVINGPATH, STATUS_LEVEL STATUS_LEVEL = status_level.value filepath = sys._getframe().f_back.f_code.co_filename @@ -139,8 +144,7 @@ def ignore_files(name: Union[str, List[str]]) -> None: @staticmethod def log( msg: Union[str, any], - status: LogStatus = LogStatus.DEBUG, - print_log: bool = False, + status: LogStatus = LogStatus.DEBUG ) -> None: r"""Log a string with status message, please do not use `\n` character in your strigs. @@ -152,6 +156,8 @@ def log( Return: None """ + print_log = literal_eval(os.environ["print_status"]) + global IGNORE_FILES_AND_DIRS cur_time = get_current_time_HM() if not isinstance(msg, str): @@ -165,7 +171,7 @@ def log( filename = os.path.split(filepath)[1] - msg = f"[{cur_time}] [{status.name:8s}] [{filename}] [{funct}]: {msg}" + msg = f"[{cur_time}] [{status.name.center(10)}] [{filename}] [{funct}]: {msg}" if print_log: print(msg)