1
0
forked from bot/app
LiteyukiBot/assets/log.html-BoVO7s7A.js

21 lines
11 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as n,o as s,c as a,e as t}from"./app-BvUYPzLF.js";const e={},o=t(`<h1 id="liteyuki-log" tabindex="-1"><a class="header-anchor" href="#liteyuki-log"><span>liteyuki.log</span></a></h1><p><strong>说明</strong>: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/7/27 上午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : log.py @Software: PyCharm</p><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) -&gt; str</code></span></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/log.py#L34" target="_blank">在GitHub上查看</a></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">&gt;</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">&#39;DEBUG&#39;</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" tabindex="-1"><a class="header-anchor" href="#def-init-log-config-dict"><span><em><strong>def</strong></em> <code>init_log(config: dict)</code></span></a></h3><p><strong>说明</strong>: 在语言加载完成后执行</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/log.py#L41" target="_blank">在GitHub上查看</a></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">&quot;&quot;&quot;
在语言加载完成后执行
Returns:
&quot;&quot;&quot;</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">&#39;log_level&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;INFO&#39;</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">&#39;log_icon&#39;</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">&#39;DEBUG&#39;</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">&#39;&lt;blue&gt;&#39;</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f&quot;</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">&#39;🐛&#39;</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">&#39;&#39;</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">DEBUG&quot;</span></span><span class="token punctuation">)</span>
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">&#39;INFO&#39;</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">&#39;&lt;normal&gt;&#39;</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f&quot;</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">&#39;&#39;</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">&#39;&#39;</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">INFO&quot;</span></span><span class="token punctuation">)</span>
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">&#39;SUCCESS&#39;</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">&#39;&lt;green&gt;&#39;</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f&quot;</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">&#39;✅&#39;</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">&#39;&#39;</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">SUCCESS&quot;</span></span><span class="token punctuation">)</span>
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">&#39;WARNING&#39;</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">&#39;&lt;yellow&gt;&#39;</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f&quot;</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">&#39;⚠️&#39;</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">&#39;&#39;</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">WARNING&quot;</span></span><span class="token punctuation">)</span>
logger<span class="token punctuation">.</span>level<span class="token punctuation">(</span><span class="token string">&#39;ERROR&#39;</span><span class="token punctuation">,</span> color<span class="token operator">=</span><span class="token string">&#39;&lt;red&gt;&#39;</span><span class="token punctuation">,</span> icon<span class="token operator">=</span><span class="token string-interpolation"><span class="token string">f&quot;</span><span class="token interpolation"><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token string">&#39;⭕&#39;</span> <span class="token keyword">if</span> show_icon <span class="token keyword">else</span> <span class="token string">&#39;&#39;</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token string">ERROR&quot;</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>`,8),p=[o];function l(i,c){return s(),a("div",null,p)}const u=n(e,[["render",l],["__file","log.html.vue"]]),k=JSON.parse('{"path":"/dev/api/log.html","title":"liteyuki.log","lang":"zh-CN","frontmatter":{"title":"liteyuki.log","lastUpdated":false,"description":"liteyuki.log 说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved @Time : 2024/7/27 上午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : log.py @Software...","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":"liteyuki.log 说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved @Time : 2024/7/27 上午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : log.py @Software..."}],["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-29T06:19:39.000Z"}],["meta",{"property":"article:modified_time","content":"2024-08-29T06:19:39.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.log\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-29T06:19:39.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)","slug":"def-init-log-config-dict","link":"#def-init-log-config-dict","children":[]}],"git":{"createdTime":1724031826000,"updatedTime":1724912379000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":5}]},"readingTime":{"minutes":0.64,"words":192},"filePathRelative":"dev/api/log.md","localizedDate":"2024年8月19日","autoDesc":true}');export{u as comp,k as data};