Skip to content

Commit

Permalink
Merge pull request #218 from uysalserkan/default-print
Browse files Browse the repository at this point in the history
Default print
  • Loading branch information
uysalserkan authored Oct 24, 2024
2 parents da2aa6b + e0101b1 commit 1c70b47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
19 changes: 1 addition & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <uysalserkan08@gmail.com>"]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Topic :: System :: Logging",
"Topic :: Text Processing :: Markup",
"Topic :: Text Processing :: Markup :: Markdown",
"Topic :: Text Processing :: Markup :: PDF",
"Topic :: Utilities",
]

Expand All @@ -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',
#]
14 changes: 10 additions & 4 deletions src/Logges/logges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit 1c70b47

Please sign in to comment.