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

This commit is contained in:
Menno van Leeuwen 2025-03-12 10:23:49 +01:00
parent 63a63e7dae
commit e1c4d5aaaf
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
3 changed files with 25 additions and 4 deletions

View File

@ -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"""

View File

@ -9,7 +9,7 @@
- name: Include ZFS tasks
ansible.builtin.include_tasks: zfs.yml
when: ansible_hostname == "mennos-server"
when: ansible_hostname == "mennos-server" or ansible_hostname == "dotfiles-test"
- name: Include services tasks
ansible.builtin.include_tasks: services/services.yml

View File

@ -2,6 +2,7 @@
ansible.builtin.package:
name:
- zfsutils-linux
- zfs-dkms
become: true
- name: Ensure ZFS kernel module is loaded