# Dida Trace **Repository Path**: zoppax/dida-trace ## Basic Information - **Project Name**: Dida Trace - **Description**: No description available - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-22 - **Last Updated**: 2024-05-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Dida Trace A common trace library for Dida Framework. Code: ## Installation ```bash composer require dida/trace ``` ## Function declaration ```php public static string $trace_path_tpl = ''; public static function setpath(string $trace_path_tpl): void public static function getpath(): string public static function log(...$args): int // 0: success, -1: failed, 1: partial success ``` ## Usage ```php use Dida\Trace; // First, set the trace path template! Or it will IGNORE all Trace::log() calls. Trace::setpath('/some/path/trace{YYYY}_{MM}_{DD}.log'); // /some/path/trace2024_01_02.log // Write trace log Trace::log('hello world'); // Write trace log with multiple arguments Trace::log($foo, $bar, $baz); ``` The path template can use the following variables: | Variable | Expression | Result | | -------- | ------------- | ------------------ | | {YYYY} | date('Y') | | | {MM} | date('m') | | | {DD} | date('d') | | | {hh} | date('H') | | | {mm} | date('i') | | | {ss} | date('s') | | | {w} | date('N') | 1-7 (1=Mon, 7=Sun) | | {www} | date('D') | Mon-Sun | | {DATE} | date('Y-m-d') | 2024-01-02 | | {date} | date('Ymd') | 20240102 | Simply, you can use `Dida\Trace::log()` to write trace log anywhere. Have fun!