Skip to content

Commit

Permalink
add environment DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
lostsnow committed Dec 29, 2021
1 parent 13d252b commit d912695
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
21 changes: 12 additions & 9 deletions README.ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ DongTai-agent-python

* Python: >=3.6
* CPython
* gcc (Linux/macOS)
* make (Linux/macOS)
* cmake
* Visual Studio (Windows)
* 编译依赖
* gcc (Linux/macOS)
* make (Linux/macOS)
* cmake
* Visual Studio (Windows)
* Web 框架
* Django: 3.0-3.2, 4.0
* Flask: 1.0-1.2, 2.0
* Django: 3.0-3.2, 4.0
* Flask: 1.0-1.2, 2.0
* Python 依赖包
* psutil: >= 5.8.0
* requests: >= 2.25.1
* pip: >= 19.2.3
* psutil: >= 5.8.0
* requests: >= 2.25.1
* pip: >= 19.2.3

## 快速上手

Expand Down Expand Up @@ -76,6 +77,7 @@ DongTai-agent-python

#### 环境变量

* 开启调试: `DEBUG=1`
* 自动创建项目: `AUTO_CREATE_PROJECT=1`
* 项目名称: `PROJECT_NAME=Demo`
* 项目版本: `PROJECT_VERSION=v1.0`
Expand All @@ -84,6 +86,7 @@ DongTai-agent-python

也可以配置 `dongtai_agent_python/config.json` 中相关的配置项,同样生效

* `debug`
* `project.name`
* `project.version`
* `engine.name`
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ DongTai-agent-python

* Python: >=3.6
* CPython
* gcc (Linux/macOS)
* make (Linux/macOS)
* cmake
* Visual Studio (Windows)
* Compiling Dependencies
* gcc (Linux/macOS)
* make (Linux/macOS)
* cmake
* Visual Studio (Windows)
* Web Framework
* Django: 3.0-3.2, 4.0
* Flask: 1.0-1.2, 2.0
* Django: 3.0-3.2, 4.0
* Flask: 1.0-1.2, 2.0
* Python packages
* psutil: >= 5.8.0
* requests: >= 2.25.1
* pip: >= 19.2.3
* psutil: >= 5.8.0
* requests: >= 2.25.1
* pip: >= 19.2.3

## Quick Start

Expand Down Expand Up @@ -81,6 +82,7 @@ Please refer to the [Quick Start](https://doc.dongtai.io/en/02_start/index.html)

#### Environment Variables

* DEBUG mode: `DEBUG=1`
* Auto Create Project: `AUTO_CREATE_PROJECT=1`
* Project Name: `PROJECT_NAME=Demo`
* Project Version: `PROJECT_VERSION=v1.0`
Expand All @@ -89,6 +91,7 @@ Please refer to the [Quick Start](https://doc.dongtai.io/en/02_start/index.html)

You can also configure the value in `dongtai_agent_python/config.json`

* `debug`
* `project.name`
* `project.version`
* `engine.name`
Expand Down
2 changes: 1 addition & 1 deletion dongtai_agent_python/common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def logger_config(logging_name):
logger = logging.getLogger(logging_name)
logger.handlers.clear()

if setting.config.get("debug"):
if setting.debug:
level = logging.DEBUG
else:
level = logging.INFO
Expand Down
4 changes: 4 additions & 0 deletions dongtai_agent_python/setting/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def init(self):
self.container = {}

self.config = Config()
self.debug = self.config.get("debug", False)
self.project_name = self.config.get('project', {}).get('name', 'Demo Project')
self.project_version = self.config.get('project', {}).get('version', '')
# engine.name will auto generated when download
Expand All @@ -44,6 +45,9 @@ def init_os_environ(self):
if not isinstance(os_env, dict):
return

if os_env.get('DEBUG', '') == '1':
self.debug = True

# windows always upper case env key
project_name = os_env.get('PROJECT_NAME', '') or os_env.get('PROJECTNAME', '') or os_env.get('projectName', '')
if project_name:
Expand Down

0 comments on commit d912695

Please sign in to comment.