mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-15 14:24:24 +08:00
21 lines
12 KiB
JavaScript
21 lines
12 KiB
JavaScript
import{_ as n,o as s,c as a,e as t}from"./app-Du8R6vOa.js";const e={},o=t(`<h3 id="def-get-format-level-str-str" tabindex="-1"><a class="header-anchor" href="#def-get-format-level-str-str"><span><em><strong>def</strong></em> <code>get_format(level: str) -> str</code></span></a></h3><details><summary>源代码</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>
|
||
<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
|
||
</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="def-init-log-config-dict-none" tabindex="-1"><a class="header-anchor" href="#def-init-log-config-dict-none"><span><em><strong>def</strong></em> <code>init_log(config: dict) -> None</code></span></a></h3><p>在语言加载完成后执行</p><p>Returns:</p><details><summary>源代码</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>
|
||
<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>
|
||
</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-logger-loguru-logger" tabindex="-1"><a class="header-anchor" href="#var-logger-loguru-logger"><span><em><strong>var</strong></em> <code>logger = loguru.logger</code></span></a></h3><h3 id="var-show-icon-config-get-log-icon-true" tabindex="-1"><a class="header-anchor" href="#var-show-icon-config-get-log-icon-true"><span><em><strong>var</strong></em> <code>show_icon = config.get('log_icon', True)</code></span></a></h3>`,8),p=[o];function l(c,i){return s(),a("div",null,p)}const u=n(e,[["render",l],["__file","log.html.vue"]]),g=JSON.parse(`{"path":"/dev/api/log.html","title":"liteyuki.log","lang":"zh-CN","frontmatter":{"title":"liteyuki.log","order":1,"icon":"laptop-code","category":"API","description":"def get_format(level: str) -> str 源代码 def init_log(config: dict) -> None 在语言加载完成后执行 Returns: 源代码 var logger = loguru.logger var show_icon = config.get('log_icon', True)","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/log.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/log.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.log"}],["meta",{"property":"og:description","content":"def get_format(level: str) -> str 源代码 def init_log(config: dict) -> None 在语言加载完成后执行 Returns: 源代码 var logger = loguru.logger var show_icon = config.get('log_icon', True)"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["meta",{"property":"og:updated_time","content":"2024-08-21T09:59:21.000Z"}],["meta",{"property":"article:modified_time","content":"2024-08-21T09:59:21.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.log\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-21T09:59:21.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"def get_format(level: str) -> str","slug":"def-get-format-level-str-str","link":"#def-get-format-level-str-str","children":[]},{"level":3,"title":"def init_log(config: dict) -> None","slug":"def-init-log-config-dict-none","link":"#def-init-log-config-dict-none","children":[]},{"level":3,"title":"var logger = loguru.logger","slug":"var-logger-loguru-logger","link":"#var-logger-loguru-logger","children":[]},{"level":3,"title":"var show_icon = config.get('log_icon', True)","slug":"var-show-icon-config-get-log-icon-true","link":"#var-show-icon-config-get-log-icon-true","children":[]}],"git":{"createdTime":1724031826000,"updatedTime":1724234361000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":4}]},"readingTime":{"minutes":0.49,"words":148},"filePathRelative":"dev/api/log.md","localizedDate":"2024年8月19日","autoDesc":true}`);export{u as comp,g as data};
|