-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
61 lines (52 loc) · 1.76 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from logmagix import Logger, Home, Loader, LogLevel
import time
import uuid
# Test ColorLogger (Style 1 - Default)
log1 = Logger(
github_repository="https://github.com/sexfrance/LogMagix",
level=LogLevel.DEBUG,
log_file="logs/color.log"
)
start_time = time.time()
log1.success("We are running style 1!")
log1.warning("Watch out, something might happen!")
log1.failure("Critical error occurred!")
log1.info("System is working properly")
log1.debug(f"The system uuid is {uuid.getnode()}")
log1.message("Dad", f"How are you? I'm gonna come soon!", start=start_time, end=time.time())
log1.question("How old are you? ")
# Test SimpleLogger (Style 2)
log2 = Logger(
style=2,
prefix="SimpleLogger",
level=LogLevel.INFO,
log_file="logs/simple.log"
)
start_time = time.time()
log2.success("We are running style 2 !")
log2.info("System is working properly")
log2.error("Critical error occurred!")
log2.warning("Watch out, something might happen!")
log2.message("System is working properly")
log2.debug(f"The system uuid is {uuid.getnode()}")
log2.question("How old are you? ")
# Test loader with custom prefix and context manager
print("\nTesting Loader:")
with Loader(prefix="custom/loader/prefix", desc="Processing data..."):
time.sleep(2) # Simulate task
# Use loader with custom prefix and start/stop methods
loader = Loader(prefix="custom/loader/prefix", desc="Saving files...", end="Done !", timeout=0.05).start()
time.sleep(2) # Simulate task
loader.stop()
# Display home screen
home_screen = Home(
text="LogMagix",
align="center",
adinfo1="Test Suite",
adinfo2="v1.0.0",
credits="Testing Framework",
clear=True
)
home_screen.display()
# Test critical error (commented out as it exits the program)
log1.critical("Critical error occurred!")