### Python Loader - Multi-Line Mode Example Source: https://pypi.org/project/logmagix-yuge/2.1.2 Demonstrates the multi-line mode of the Loader class, allowing simultaneous monitoring of multiple tasks. It shows how to start multiple loaders, update their descriptions dynamically, and stop them. ```python from logmagix import Loader import time # 创建多个任务(设置 multiline=True) loader1 = Loader(prefix="任务1", desc="运行中...", multiline=True).start() loader2 = Loader(prefix="任务2", desc="运行中...", multiline=True).start() loader3 = Loader(prefix="任务3", desc="运行中...", multiline=True).start() # 动态更新 loader1.desc = "步骤1: 准备数据..." loader2.desc = "步骤2: 处理数据..." loader3.desc = "步骤3: 保存结果..." time.sleep(3) # 停止 loader1.stop() loader2.stop() loader3.stop() time.sleep(1) # 等待自动清理 print("完成!") ``` -------------------------------- ### Install logmagix-yuge Source: https://pypi.org/project/logmagix-yuge/index Instructions for installing the logmagix-yuge package using pip. This is the primary method for adding the library to your Python environment. Alternatively, you can install from source by installing its dependencies. ```bash pip install logmagix-yuge ``` ```bash pip install colorama pystyle packaging requests ``` -------------------------------- ### Install Dependencies for Source Installation Source: https://pypi.org/project/logmagix-yuge/2.1.2 Installs the necessary dependencies if you are installing logmagix-yuge from source. These packages include colorama, pystyle, packaging, and requests, which are required for full functionality. ```bash pip install colorama pystyle packaging requests ``` -------------------------------- ### Python Loader - Dynamic Progress Update Example Source: https://pypi.org/project/logmagix-yuge/2.1.2 Shows a practical example of using the Loader in multi-line mode to display dynamic progress updates, such as a download percentage. The loader's description is updated in a loop. ```python from logmagix import Loader import time loader = Loader(prefix="下载", desc="0%", multiline=True).start() for i in range(1, 101): loader.desc = f"下载进度: {i}%" time.sleep(0.05) loader.stop() time.sleep(1) ``` -------------------------------- ### Python Loader - Single-Line Dynamic Update (Manual Control) Source: https://pypi.org/project/logmagix-yuge/2.1.2 Shows how to use the Loader class for single-line dynamic updates. This example manually starts the loader, simulates work with time.sleep, and then stops the loader. ```python from logmagix import Loader import time # 方式1: 手动控制 loader = Loader(prefix="任务", desc="处理中...").start() time.sleep(3) loader.stop() ``` -------------------------------- ### Install logmagix-yuge Package Source: https://pypi.org/project/logmagix-yuge/2.1.2 Installs the logmagix-yuge package using pip. This command ensures you have the latest version of the library available for use in your Python projects. ```bash pip install logmagix-yuge==2.1.2.9 ``` -------------------------------- ### Python Logger - File Logging Example Source: https://pypi.org/project/logmagix-yuge/2.1.2 Demonstrates how to configure the Logger to save logs to a file in addition to displaying them on the console. The `log_file` parameter specifies the path to the log file. ```python from logmagix import Logger log = Logger( prefix="MyApp", log_file="logs/app.log" ) log.info("这条日志会同时输出到控制台和文件") ``` -------------------------------- ### API Reference - Loader Class (Python) Source: https://pypi.org/project/logmagix-yuge/index Provides an overview of the Loader class constructor parameters and available methods/attributes. It details options for prefix, description, end text, timeout for animations, and the multi-line mode switch. Key methods like start() and stop(), and the writable 'desc' attribute are also explained. ```python Loader( prefix: str = "Task", # 任务名称 desc: str = "Loading...", # 描述文本(可更新) end: str = "\r", # 结束文本 timeout: float = 0.1, # 动画间隔(单行模式) multiline: bool = False # 多行模式开关 ) # 方法: # * `start()` - 启动 Loader # * `stop()` - 停止 Loader # 属性: # * `desc` - 描述文本(可读写) ``` -------------------------------- ### Python Logger - Log Level Control Example Source: https://pypi.org/project/logmagix-yuge/2.1.2 Illustrates how to control the minimum log level displayed by the Logger. This example sets the level to WARNING, so only WARNING and ERROR messages will be shown. ```python from logmagix import Logger, LogLevel # 只显示 WARNING 及以上级别 log = Logger(prefix="MyApp", level=LogLevel.WARNING) log.debug("不会显示") log.info("不会显示") log.warning("会显示") log.error("会显示") ``` -------------------------------- ### Python Loader - Multi-Threaded Task Monitoring Example Source: https://pypi.org/project/logmagix-yuge/2.1.2 Demonstrates how to monitor multiple concurrent tasks using the Loader in multi-line mode with Python's threading module. Each thread manages its own loader to display progress. ```python from logmagix import Loader import time import threading def worker(task_id): loader = Loader( prefix=f"线程{task_id}", desc="处理中...", end="完成!", multiline=True ).start() # 模拟工作 for i in range(10): loader.desc = f"进度: {i*10}%" time.sleep(0.3) loader.stop() # 启动 3 个并发任务 threads = [threading.Thread(target=worker, args=(i,)) for i in range(1, 4)] for t in threads: t.start() for t in threads: t.join() time.sleep(1) print("所有任务完成!") ``` -------------------------------- ### Python Loader - Single-Line Dynamic Update (Context Manager) Source: https://pypi.org/project/logmagix-yuge/2.1.2 Illustrates using the Loader class as a context manager for single-line dynamic updates. The loader automatically starts and stops when entering and exiting the 'with' block. ```python from logmagix import Loader import time # 方式2: Context Manager with Loader(prefix="任务", desc="处理中...", end="完成!"): time.sleep(3) ``` -------------------------------- ### Loader - Single-Line Dynamic (Python) Source: https://pypi.org/project/logmagix-yuge/index Shows how to use the Loader class for single-line dynamic updates, such as a loading spinner. It can be controlled manually by starting and stopping the loader, or used as a context manager for automatic handling. This is useful for indicating ongoing processes. ```python from logmagix import Loader import time # 方式1: 手动控制 loader = Loader(prefix="任务", desc="处理中...").start() time.sleep(3) loader.stop() # 方式2: Context Manager with Loader(prefix="任务", desc="处理中...", end="完成!"): time.sleep(3) ``` -------------------------------- ### Python Logger - Colored Logs Source: https://pypi.org/project/logmagix-yuge/2.1.2 Demonstrates how to use the Logger class for colored logging with different severity levels (info, success, warning, error). The Logger is initialized with a prefix for identification. ```python from logmagix import Logger log = Logger(prefix="MyApp") log.info("应用启动") log.success("操作成功") log.warning("警告信息") log.error("错误信息") ``` -------------------------------- ### API Reference - Logger Class (Python) Source: https://pypi.org/project/logmagix-yuge/index Details the Logger class constructor parameters and available logging methods. It covers style options (colored or concise), prefix customization, log level filtering, and file logging configuration. The logging methods (debug, info, warning, success, error, critical) are also listed. ```python Logger( style: int = 1, # 样式(1=彩色,2=简洁) prefix: str = "App", # 日志前缀 level: LogLevel = DEBUG, # 最低日志级别 log_file: str = None # 日志文件路径 ) # 方法: # * `debug(msg)` - 调试日志 # * `info(msg)` - 信息日志 # * `warning(msg)` - 警告日志 # * `success(msg)` - 成功日志 # * `error(msg)` - 错误日志 # * `critical(msg)` - 严重错误 ``` -------------------------------- ### Customize Loader Animation Steps in Python Source: https://pypi.org/project/logmagix-yuge/2.1.2 This code snippet demonstrates how to change the animation style of the loader by modifying the `loader.steps` attribute. Ensure this is done correctly within the project's context to apply custom animations. ```python loader.steps = ["◐", "◓", "◑", "◒"] ``` -------------------------------- ### Python Loader - Multi-Line Mode - Auto Stop Wait Source: https://pypi.org/project/logmagix-yuge/2.1.2 Explains the importance of waiting for the automatic stop mechanism in multi-line mode for Loaders. This ensures that all loader elements are properly cleared before subsequent output. ```python loader1.stop() loader2.stop() time.sleep(1) # 等待 Manager 自动停止 ``` -------------------------------- ### Modify Loader Animation Steps (Python) Source: https://pypi.org/project/logmagix-yuge/index This snippet demonstrates how to change the animation characters used by the LogMagix loader. It involves directly modifying the `loader.steps` attribute to a new list of characters. ```python loader.steps = ["◐", "◓", "◑", "◒"] ``` -------------------------------- ### Python Loader - Multi-Line Mode - Incorrect Print Usage Source: https://pypi.org/project/logmagix-yuge/2.1.2 Highlights an incorrect usage pattern when using the Loader in multi-line mode: directly using `print()` while the loader is active. This can disrupt the rendering of the loader. ```python # ❌ 错误 loader.start() print("启动") # 破坏渲染 # ✅ 正确 loader.start() loader.stop() time.sleep(1) print("完成") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.