mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-29 20:05:25 +08:00
docs: add code style guide in English, Japanese, and Chinese
This commit is contained in:
@@ -230,6 +230,7 @@ export default defineConfig({
|
||||
{ text: "消息平台实体", link: "/zh/plugin/dev/apis/messages" },
|
||||
],
|
||||
},
|
||||
{ text: "代码规范", link: "/zh/plugin/dev/style" },
|
||||
{ text: "迁移指南", link: "/zh/plugin/dev/migration" },
|
||||
{
|
||||
text: "分发插件", collapsed: true,
|
||||
@@ -513,6 +514,7 @@ export default defineConfig({
|
||||
{ text: "Message Platform Entities", link: "/en/plugin/dev/apis/messages" },
|
||||
],
|
||||
},
|
||||
{ text: "Code Style", link: "/en/plugin/dev/style" },
|
||||
{ text: "Migration Guide", link: "/en/plugin/dev/migration" },
|
||||
{
|
||||
text: "Distribute Plugin", collapsed: true,
|
||||
@@ -773,6 +775,7 @@ export default defineConfig({
|
||||
{ text: "メッセージプラットフォームエンティティ", link: "/ja/plugin/dev/apis/messages" },
|
||||
],
|
||||
},
|
||||
{ text: "コードスタイル", link: "/ja/plugin/dev/style" },
|
||||
{ text: "移行ガイド", link: "/ja/plugin/dev/migration" },
|
||||
{
|
||||
text: "プラグインを配布", collapsed: true,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Code Style Guide
|
||||
|
||||
## Logging
|
||||
|
||||
In plugins, please use the `logging` module to record logs, do not use `print` statements (this will cause logs to not be output in the container environment).
|
||||
|
||||
```python
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__) # Import logging module at the beginning of any Python file and define logger object
|
||||
|
||||
logger.info('This is an info message') # Use logger.info to record info level logs
|
||||
logger.warning('This is a warning message')
|
||||
logger.error('This is an error message')
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
# コードスタイルガイド
|
||||
|
||||
## ロギング
|
||||
|
||||
プラグインでは、`logging`モジュールを使用してログを記録してください。`print`文を使用しないでください(これはコンテナ環境でログが出力されなくなります)。
|
||||
|
||||
```python
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__) # 任意の Python ファイルの先頭で logging モジュールをインポートし、logger オブジェクトを定義します
|
||||
|
||||
logger.info('This is an info message') # logger.info を使用して info レベルのログを記録します
|
||||
logger.warning('This is a warning message')
|
||||
logger.error('This is an error message')
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
# 代码规范指南
|
||||
|
||||
## 日志记录
|
||||
|
||||
在插件中请使用`logging`模块记录日志,不要使用`print`语句(这将导致容器环境中无法输出日志)。
|
||||
|
||||
```python
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__) # 在任何 Python 文件的开头导入 logging 模块,并定义 logger 对象
|
||||
|
||||
logger.info('This is an info message') # 使用 logger.info 记录信息级别日志
|
||||
logger.warning('This is a warning message')
|
||||
logger.error('This is an error message')
|
||||
```
|
||||
Reference in New Issue
Block a user