瀏覽代碼

Use proper logging routines

master
Chris Smith 6 年之前
父節點
當前提交
06666581ce
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5
    5
      main.py

+ 5
- 5
main.py 查看文件

86
     return app.send_static_file("index.html")
86
     return app.send_static_file("index.html")
87
 
87
 
88
 
88
 
89
-@app.route("/hooks/gitea/<path:repo>/<hash>", methods=['POST'])
89
+@app.route("/hooks/gitea/<path:repo>/<hash>", methods=["POST"])
90
 def handle_hook_gitea(repo, hash):
90
 def handle_hook_gitea(repo, hash):
91
-    print(f"Received hook for repo {repo} with has {hash}")
91
+    app.logger.info(f"Received hook for repo {repo} with has {hash}")
92
     expected_hash = get_hook_key("gitea", repo)
92
     expected_hash = get_hook_key("gitea", repo)
93
     if hash != expected_hash:
93
     if hash != expected_hash:
94
-        print(f"Hash mismatch: expected {expected_hash}")
94
+        app.logger.info(f"Hash mismatch: expected {expected_hash}")
95
         abort(403)
95
         abort(403)
96
 
96
 
97
     if repo not in repos:
97
     if repo not in repos:
98
-        print(f"Repository not found. Known repos: {repos.keys()}")
98
+        app.logger.info(f"Repository not found. Known repos: {repos.keys()}")
99
         abort(404)
99
         abort(404)
100
 
100
 
101
     urls = repos[repo]
101
     urls = repos[repo]
102
     for name, spec, url in jobs:
102
     for name, spec, url in jobs:
103
         if url in urls:
103
         if url in urls:
104
             # TODO: Check branches
104
             # TODO: Check branches
105
-            print(f"Found matching job: {name} with URL {url}")
105
+            app.logger.info(f"Found matching job: {name} with URL {url}")
106
             jenkins_server.build_job(name)
106
             jenkins_server.build_job(name)
107
 
107
 
108
     return "", 204
108
     return "", 204

Loading…
取消
儲存