Skip to content

Commit b7b413b

Browse files
author
esfiam
committed
Clean up test files and consolidate into single demo
- Remove unnecessary debug files (debug_colors.py, simple_color_test.py, vscode_test.py) - Enhance demo_smartlogger.py with comprehensive tests: • Environment detection • Direct ANSI color test • SmartLogger status check • Force color testing • Better troubleshooting guidance - Single file now contains all testing functionality
1 parent ac7a05a commit b7b413b

4 files changed

Lines changed: 55 additions & 208 deletions

File tree

debug_colors.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

demo_smartlogger.py

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
#!/usr/bin/env python3
22
"""
3-
SmartLogger Demo - نمایش قابلیت‌های رنگی سیستم لاگ
3+
SmartLogger Complete Demo - تست جامع قابلیت‌های رنگی
44
"""
55

66
import time
77
import logging
8+
import os
9+
import sys
10+
11+
print("🔍 SmartLogger Environment Check:")
12+
print(f"Terminal supports colors: {sys.stdout.isatty()}")
13+
print(f"Platform: {sys.platform}")
14+
print(f"TERM: {os.environ.get('TERM', 'Not set')}")
15+
16+
# تست رنگ ANSI مستقیم
17+
print("\n🎨 Direct ANSI Color Test:")
18+
print(f"\033[31mRed\033[0m \033[32mGreen\033[0m \033[33mYellow\033[0m \033[34mBlue\033[0m")
19+
20+
# فعال کردن force color برای اطمینان
21+
os.environ['FORCE_COLOR'] = '1'
822

923
# فعالسازی SmartLogger
1024
import smartlogger.auto
@@ -146,11 +160,42 @@ def demo_error_scenarios():
146160
getattr(error_logger, level)(f"{level.upper()}: {message}")
147161
time.sleep(0.5)
148162

163+
def demo_force_color_test():
164+
"""تست با force color برای محیط‌های مختلف"""
165+
print("\n🔧 === Demo: Force Color Test ===")
166+
167+
from smartlogger import ColoredStreamHandler, ColoredFormatter
168+
169+
# ایجاد handler با force color
170+
handler = ColoredStreamHandler(sys.stdout, force_color=True)
171+
formatter = ColoredFormatter('%(levelname)s: %(message)s')
172+
handler.setFormatter(formatter)
173+
174+
force_logger = logging.getLogger('ForceColor')
175+
force_logger.handlers.clear()
176+
force_logger.addHandler(handler)
177+
force_logger.setLevel(logging.DEBUG)
178+
179+
force_logger.debug("Force DEBUG (should be blue)")
180+
force_logger.info("Force INFO (should be green)")
181+
force_logger.warning("Force WARNING (should be yellow)")
182+
force_logger.error("Force ERROR (should be red)")
183+
force_logger.critical("Force CRITICAL (should be bold red)")
184+
149185
def main():
150186
"""اجرای تمام demo ها"""
151-
print("🎯 SmartLogger Demonstration")
187+
print("\n🎯 SmartLogger Complete Demonstration")
152188
print("=" * 50)
153-
print("نمایش قابلیت‌های رنگی سیستم لاگ پایتون")
189+
190+
# بررسی وضعیت SmartLogger
191+
try:
192+
from smartlogger.auto import is_active
193+
from smartlogger.utils.terminal import supports_colors
194+
print(f"SmartLogger Active: {is_active()}")
195+
print(f"Color Support: {supports_colors()}")
196+
except Exception as e:
197+
print(f"SmartLogger Status Error: {e}")
198+
154199
print("=" * 50)
155200

156201
# اجرای تمام demo ها
@@ -159,15 +204,15 @@ def main():
159204
demo_custom_colors()
160205
demo_multiple_loggers()
161206
demo_error_scenarios()
207+
demo_force_color_test()
162208

163209
print("\n✅ === Demo Completed ===")
164-
print("تمام قابلیت‌های SmartLogger نمایش داده شد!")
165-
print("رنگ‌ها بر اساس سطح لاگ تنظیم شده‌اند:")
166-
print("🔵 DEBUG (آبی)")
167-
print("🟢 INFO (سبز)")
168-
print("🟡 WARNING (زرد)")
169-
print("🔴 ERROR (قرمز)")
170-
print("🟥 CRITICAL (قرمز Bold)")
210+
print("🎨 If you see colors above, SmartLogger is working!")
211+
print("🔧 If you don't see colors:")
212+
print(" • Try running in Terminal.app (not VSCode)")
213+
print(" • Use iTerm2 on macOS")
214+
print(" • Check terminal ANSI color support")
215+
print(" • Set FORCE_COLOR=1 environment variable")
171216

172217
if __name__ == "__main__":
173218
main()

simple_color_test.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

vscode_test.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)