2024-08-29 13:55:15 +08:00
|
|
|
|
import{_ as n,o as s,c as a,d as t}from"./app-CLi4lRj1.js";const e={},o=t(`<h3 id="func-get-format-str" tabindex="-1"><a class="header-anchor" href="#func-get-format-str"><span><em>func</em> <code>get_format() -> str</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">get_format</span><span class="token punctuation">(</span>level<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">str</span><span class="token punctuation">:</span>
|
2024-08-21 18:00:26 +08:00
|
|
|
|
<span class="token keyword">if</span> level <span class="token operator">==</span> <span class="token string">'DEBUG'</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">return</span> debug_format
|
|
|
|
|
<span class="token keyword">else</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">return</span> default_format
|
2024-08-29 13:53:08 +08:00
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="func-init-log" tabindex="-1"><a class="header-anchor" href="#func-init-log"><span><em>func</em> <code>init_log()</code></span></a></h3><p><strong>说明</strong>: 在语言加载完成后执行</p><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">init_log</span><span class="token punctuation">(</span>config<span class="token punctuation">:</span> <span class="token builtin">dict</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
2024-08-21 18:00:26 +08:00
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
在语言加载完成后执行
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>remove<span class="token punctuation">(</span><span class="token punctuation">)</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>add<span class="token punctuation">(</span>sys<span class="token punctuation">.</span>stdout<span class="token punctuation">,</span> level<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> diagnose<span class="token operator">=</span><span class="token boolean">False</span><span class="token punctuation">,</span> <span class="token builtin">format</span><span class="token operator">=</span>get_format<span class="token punctuation">(</span>config<span class="token punctuation">.</span>get<span class="token punctuation">(</span><span class="token string">'log_level'</span><span class="token punctuation">,</span> <span class="token string">'INFO'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
show_icon <span class="token operator">=</span> config<span class="token punctuation">.</span>get<span class="token punctuation">(</span><span class="token string">'log_icon'</span><span class="token punctuation">,</span> <span class="token boolean">True</span><span class="token punctuation">)</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">'DEBUG'</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">'<blue>'</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f"</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">'🐛'</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">DEBUG"</span></span><span class="token punctuation">)</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">'INFO'</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">'<normal>'</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f"</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">'ℹ️'</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">INFO"</span></span><span class="token punctuation">)</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">'SUCCESS'</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">'<green>'</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f"</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">'✅'</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">SUCCESS"</span></span><span class="token punctuation">)</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">'WARNING'</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">'<yellow>'</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f"</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">'⚠️'</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">WARNING"</span></span><span class="token punctuation">)</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">'ERROR'</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">'<red>'</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f"</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">'⭕'</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">ERROR"</span></span><span class="token punctuation">)</span>
|
2024-08-29 13:53:08 +08:00
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="var-debug-format-c-time-yyyy-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-module-function-line-c-message" tabindex="-1"><a class="header-anchor" href="#var-debug-format-c-time-yyyy-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-module-function-line-c-message"><span><em><strong>var</strong></em> <code>debug_format = '<c>{time:YYYY-MM-DD HH:mm:ss}</c> <lvl>[{level.icon}]</lvl> <c><{name}.{module}.{function}:{line}></c> {message}'</code></span></a></h3><ul><li><strong>类型</strong>: <code>str</code></li></ul><h3 id="var-default-format-c-time-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-c-message" tabindex="-1"><a class="header-anchor" href="#var-default-format-c-time-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-c-message"><span><em><strong>var</strong></em> <code>default_format = '<c>{time:MM-DD HH:mm:ss}</c> <lvl>[{level.icon}]</lvl> <c><{name}></c> {message}'</code></span></a></h3><ul><li><strong>类型</strong>: <code>str</code></li></ul>`,9),l=[o];function p(c,i){return s(),a("div",null,l)}const r=n(e,[["render",p],["__file","log.html.vue"]]),m=JSON.parse(`{"path":"/api/log.html","title":"liteyuki.log","lang":"zh-CN","frontmatter":{"title":"liteyuki.log","description":"func get_format() -> str 源代码 func init_log() 说明: 在语言加载完成后执行 源代码 var debug_format = '<c>{time:YYYY-MM-DD HH:mm:ss}</c> <lvl>[{level.icon}]</lvl> <c><{name}.{module}.{function}:{l...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/api/log.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/api/log.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.log"}],["meta",{"property":"og:description","content":"func get_format() -> str 源代码 func init_log() 说明: 在语言加载完成后执行 源代码 var debug_format = '<c>{time:YYYY-MM-DD HH:mm:ss}</c> <lvl>[{level.icon}]</lvl> <c><{name}.{module}.{function}:{l..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.log\\",\\"image\\":[\\"\\"],\\"dateModified\\":null,\\"author\\":[]}"]]},"headers":[{"level":3,"title":"func get_format() -> str","slug":"func-get-format-str","link":"#func-get-format-str","children":[]},{"level":3,"title":"func init_log()","slug":"func-init-log","link":"#func-init-log","children":[]},{"level":3,"title":"var debug_format = '<c>{time:YYYY-MM-DD HH:mm:ss}</c> <lvl>[{level.icon}]</lvl> <c><{name}.{module}.{function}:{line}></c> {message}'","slug":"var-debug-format-c-time-yyyy-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-module-function-line-c-message","link":"#var-debug-format-c-time-yyyy-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-module-function-line-c-message","children":[]},{"level":3,"title":"var default_format = '<c>{time:MM-DD HH:mm:ss}</c> <lvl>[{level.icon}]</lvl> <c><{name}></c> {message}'","slug":"var-default-format-c-time-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-c-message","link":"#var-default-format-c-time-mm-dd-hh-mm-ss-c-lvl-level-icon-lvl-c-name-c-message","children":[]}],"git":{"createdTime":null,"updatedTime":null,"contributors":[]},"readingTime":{"minutes":0.6,"words":179},"filePathR
|