This is an automated email from the ASF dual-hosted git repository.
hxb pushed a commit to branch release-1.13
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.13 by this push:
new 75fddd3 [hotfix][python][docs] Add missing debugging page for PyFlink
documentation
75fddd3 is described below
commit 75fddd30611e67c24775613ed4d5a4a1caa1e0a7
Author: huangxingbo <[email protected]>
AuthorDate: Tue Apr 27 11:12:47 2021 +0800
[hotfix][python][docs] Add missing debugging page for PyFlink documentation
---
docs/content.zh/docs/dev/python/debugging.md | 72 +++++++++++++++++++++++++++
docs/content/docs/dev/python/debugging.md | 73 ++++++++++++++++++++++++++++
2 files changed, 145 insertions(+)
diff --git a/docs/content.zh/docs/dev/python/debugging.md
b/docs/content.zh/docs/dev/python/debugging.md
new file mode 100644
index 0000000..e5da443
--- /dev/null
+++ b/docs/content.zh/docs/dev/python/debugging.md
@@ -0,0 +1,72 @@
+---
+title: "调试"
+weight: 130
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# 调试
+
+本页介绍如何在PyFlink进行调试
+
+## 打印日志信息
+
+Python UDF可以通过标准的Python logging模块记录上下文和调试信息。
+
+```python
+@udf(input_types=[DataTypes.BIGINT(), DataTypes.BIGINT()],
result_type=DataTypes.BIGINT())
+def add(i, j):
+ import logging
+ logging.info("debug")
+ return i + j
+```
+
+## 查看日志
+
+如果设置了环境变量`FLINK_HOME`,日志将会放置在`FLINK_HOME`指向目录的log目录之下。否则,日志将会放在安装的Pyflink模块的
+log目录下。你可以通过执行下面的命令来查找PyFlink模块的log目录的路径:
+
+```bash
+$ python -c "import pyflink;import
os;print(os.path.dirname(os.path.abspath(pyflink.__file__))+'/log')"
+```
+
+## 调试Python UDFs
+你可以利用PyCharm提供的[`pydevd_pycharm`](https://pypi.org/project/pydevd-pycharm/)工具进行Python
UDF的调试
+
+1. 在PyCharm里创建一个Python Remote Debug
+
+ run -> Python Remote Debug -> + -> 选择一个port (e.g. 6789)
+
+2. 安装`pydevd-pycharm`工具
+
+ ```bash
+ $ pip install pydevd-pycharm
+ ```
+
+3. 在你的Python UDF里面添加如下的代码
+
+ ```python
+ import pydevd_pycharm
+ pydevd_pycharm.settrace('localhost', port=6789, stdoutToServer=True,
stderrToServer=True)
+ ```
+
+4. 启动刚刚创建的Python Remote Dubug Server
+
+5. 运行你的Python代码
diff --git a/docs/content/docs/dev/python/debugging.md
b/docs/content/docs/dev/python/debugging.md
new file mode 100644
index 0000000..6a64d5e
--- /dev/null
+++ b/docs/content/docs/dev/python/debugging.md
@@ -0,0 +1,73 @@
+---
+title: "Debugging"
+weight: 130
+type: docs
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Debugging
+
+This page describes how to debug in PyFlink.
+
+## Logging Infos
+
+Python UDFs can log contextual and debug information via standard Python
logging modules.
+
+```python
+@udf(input_types=[DataTypes.BIGINT(), DataTypes.BIGINT()],
result_type=DataTypes.BIGINT())
+def add(i, j):
+ import logging
+ logging.info("debug")
+ return i + j
+```
+
+## Accessing Logs
+
+If the environment variable `FLINK_HOME` is set, logs will be written in the
log directory under `FLINK_HOME`.
+Otherwise, logs will be placed in the directory of the PyFlink module. You can
execute the following command to find
+the log directory of the PyFlink module:
+
+```bash
+$ python -c "import pyflink;import
os;print(os.path.dirname(os.path.abspath(pyflink.__file__))+'/log')"
+```
+
+## Debugging Python UDFs
+You can make use of the
[`pydevd_pycharm`](https://pypi.org/project/pydevd-pycharm/) tool of PyCharm to
debug Python UDFs.
+
+1. Create a Python Remote Debug in PyCharm
+
+ run -> Python Remote Debug -> + -> choose a port (e.g. 6789)
+
+2. Install the `pydevd-pycharm` tool
+
+ ```bash
+ $ pip install pydevd-pycharm
+ ```
+
+3. Add the following command in your Python UDF
+
+ ```python
+ import pydevd_pycharm
+ pydevd_pycharm.settrace('localhost', port=6789, stdoutToServer=True,
stderrToServer=True)
+ ```
+
+4. Start the previously created Python Remote Debug Server
+
+5. Run your Python Code