Skip to content

Commit

Permalink
new stuff:
Browse files Browse the repository at this point in the history
- Logging().starting(text)
- more line wrapping for "\n"
- removal of Logging().beans(text)
(it had to be done eventually)
  • Loading branch information
Bernso committed Feb 6, 2025
1 parent 4156fe2 commit 802d900
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pip install boLogger --upgrade

- Colour
- Create your own custom logger
- Text wrapping (the text will never be on the same level as the logger info)
- Text wrapping
- the text will never be on the same level as the logger info
- "\n" will now triiger a text wrap aswell now, before they where mysteriously removed from existence
- Easy use

# Options
Expand Down Expand Up @@ -44,6 +46,11 @@ B stands for bright
## Options for Logging()

```py
#each of these have 3 args:
#- text (str)
#- bold (bool)
#- unnderlined (bool)

.header(text)

.info(text)
Expand All @@ -54,6 +61,8 @@ B stands for bright

.success(text)

.starting(text)

.input(text)

.set_colour(
Expand Down Expand Up @@ -112,7 +121,7 @@ myLogger.error("Error")

myLogger.success("Success")

myLogger.beans("Beans")
myLogger.starting("Starting")

myLogger.info("This is a very long log message that is going to spill over to the next line and needs to be properly indented for better readability.")

Expand Down
29 changes: 16 additions & 13 deletions boLogger/boLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init__(self, len=30):
"warning": self.colors['BYellow'],
"error": self.colors['BRed'],
"success": self.colors['BGreen'],
"beans": self.colors['BBlue'],
"input": self.colors['Yellow'],
"starting": self.colors['BBlue']
}


Expand Down Expand Up @@ -77,6 +77,7 @@ def __creator(self, title, colour, text, bold=False, underlined=False, enditem='
# Break the text into lines
wrapped_lines = []
line_length = 160 - self.len # Adjust line length to account for prefix
text = text.replace('\n', (' ' * line_length))
words = text.split(' ') # Only remove trailing spaces if necessary
current_line = ""

Expand Down Expand Up @@ -148,15 +149,6 @@ def success(self, text, bold=False, underlined=False):
underlined=underlined
)

def beans(self, text, bold=False, underlined=False):
self.__creator(
title='beans',
colour=self.logColourDeafults['beans'],
text=text,
bold=bold,
underlined=underlined
)

def input(self, text, bold=False, underlined=False):
self.__creator(
title='input',
Expand All @@ -169,6 +161,16 @@ def input(self, text, bold=False, underlined=False):
choice = input() # I don't know how this still works lmao
return choice

def starting(self, text, bold=False, underlined=False):
self.__creator(
title="starting",
colour=self.logColourDeafults['starting'],
text=text,
bold=bold,
underlined=underlined
)


def set_colour(self, method: str, colour: str):
"""
Lets you change the colour for an already existing method
Expand All @@ -180,7 +182,7 @@ def set_colour(self, method: str, colour: str):
self.info(f"All of the deafult colours codes: {self.colors.values()}")
return

methods = ['info', 'success', 'error', 'warning', 'beans', 'input', 'header']
methods = ['info', 'success', 'error', 'warning', 'input', 'header', 'starting']
if method.lower() not in methods:
self.error("Invalid method name")
self.info(f"All method names: {''.join(methods)}")
Expand Down Expand Up @@ -312,19 +314,20 @@ def view_deafult(self):
# Make sure to define the class
mylogger = Logging()
print(mylogger)

mylogger.header("Header")
mylogger.info("Info")
mylogger.warning("Warning")
mylogger.error("Error")
mylogger.success("Success")
mylogger.beans("Beans")
mylogger.info("This is a very long log message that is going to spill over to the next line and needs to be properly indented for better readability.")
mylogger.info("This is info")
mylogger.set_colour('info', 'BBlack')
mylogger.info("This is the new info")
mylogger.starting("This is a new proccess starting")
num = mylogger.input("This is an input, please enter a number: ")
mylogger.info(f"The user has entered: {num}")

customLogger = CustomLog()
print(customLogger)
customLogger.set_default_custom(title="beansareyummy", color='Blue')
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "boLogger" # Use a unique name
version = "0.1.4.1" # Start with a low version number
version = "0.1.5.0" # Start with a low version number
description = "An advanced logging system used for clear understanding of your logs."
authors = ["Bernso <Bernso@duck.com>"]
license = "MIT" # Choose an appropriate license
Expand Down

0 comments on commit 802d900

Please sign in to comment.