feat: enhance printfe function to include timestamp and message type, and update server tasks for dotfiles-test
Some checks failed
Nix Format Check / check-format (push) Failing after 37s
Some checks failed
Nix Format Check / check-format (push) Failing after 37s
This commit is contained in:
@ -6,6 +6,7 @@ import subprocess
|
||||
import math
|
||||
import random
|
||||
import shutil
|
||||
import datetime
|
||||
try:
|
||||
import pyfiglet
|
||||
except ImportError:
|
||||
@ -21,12 +22,31 @@ COLORS = {
|
||||
"purple": "\033[0;35m",
|
||||
"cyan": "\033[0;36m",
|
||||
"white": "\033[0;37m",
|
||||
"grey": "\033[0;90m", # Added grey color for timestamp
|
||||
"reset": "\033[0m"
|
||||
}
|
||||
|
||||
def printfe(color, message):
|
||||
"""Print a formatted message with the specified color"""
|
||||
def printfe(color, message, show_time=True):
|
||||
"""
|
||||
Print a formatted message with the specified color
|
||||
With timestamp and message type prefix similar to setup.sh
|
||||
"""
|
||||
color_code = COLORS.get(color.lower(), COLORS["reset"])
|
||||
|
||||
if show_time:
|
||||
# Add timestamp
|
||||
timestamp = datetime.datetime.now().strftime('%H:%M:%S')
|
||||
print(f"{COLORS['grey']}{timestamp}{COLORS['reset']}", end='')
|
||||
|
||||
# Add message type based on color
|
||||
if color.lower() in ["green", "cyan", "blue", "purple"]:
|
||||
print(f"{COLORS['green']} INF {COLORS['reset']}", end='')
|
||||
elif color.lower() == "yellow":
|
||||
print(f"{COLORS['yellow']} WRN {COLORS['reset']}", end='')
|
||||
elif color.lower() == "red":
|
||||
print(f"{COLORS['red']} ERR {COLORS['reset']}", end='')
|
||||
|
||||
# Print the actual message with color
|
||||
print(f"{color_code}{message}{COLORS['reset']}")
|
||||
|
||||
def println(message, color=None):
|
||||
@ -34,7 +54,7 @@ def println(message, color=None):
|
||||
if color:
|
||||
printfe(color, message)
|
||||
else:
|
||||
print(message)
|
||||
printfe("reset", message)
|
||||
|
||||
def _rainbow_color(text, freq=0.1, offset=0):
|
||||
"""Apply rainbow colors to text similar to lolcat"""
|
||||
|
Reference in New Issue
Block a user