浏览代码

New logging

mod_update
Dirk Alders 4 年前
父节点
当前提交
12aeefae37
共有 9 个文件被更改,包括 22 次插入33 次删除
  1. 6
    2
      .gitignore
  2. 9
    24
      config_example/config.py
  3. 1
    1
      leyk.py
  4. 1
    1
      report
  5. 1
    1
      socket_protocol
  6. 1
    1
      state_machine
  7. 1
    1
      stringtools
  8. 1
    1
      task
  9. 1
    1
      tcp_socket

+ 6
- 2
.gitignore 查看文件

@@ -1,11 +1,15 @@
1
+config.py
2
+.settings
3
+*~
4
+messages.*
5
+
6
+
1 7
 # ---> Python
2 8
 # Byte-compiled / optimized / DLL files
3 9
 __pycache__/
4 10
 *.py[cod]
5 11
 *$py.class
6 12
 
7
-config.py
8
-
9 13
 # C extensions
10 14
 *.so
11 15
 

+ 9
- 24
config_example/config.py 查看文件

@@ -1,36 +1,21 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: UTF-8 -*-
3 3
 
4
-import geo
5
-import socket_protocol
6
-import state_machine
7
-import stringtools
8
-import task
9
-import tcp_socket
4
+import report
10 5
 
11 6
 secret = b'give_a_secret_string_here'
12 7
 server_ip = '127.0.0.1'
13 8
 server_port = 10001
14 9
 
10
+# Logging
11
+#
12
+APP_NAME = 'leyk'
13
+
15 14
 LOG_TARGET_STDOUT = 'stdout'
16 15
 LOG_TARGET_FILE = 'logfile'
17
-LOG_TARGET = LOG_TARGET_STDOUT
18
-
16
+LOGTARGET = LOG_TARGET_STDOUT
19 17
 
20
-SHORT_FMT = "%(asctime)s: %(levelname)-7s - %(message)s"
21
-""" A short formatter including the most important information"""
22
-LONG_FMT = """~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23
-File "%(pathname)s", line %(lineno)d, in %(funcName)s
24
-%(asctime)s: %(levelname)-7s - %(message)s"""
25
-""" A long formatter which results in links to the source code inside Eclipse"""
18
+LOGHOST = 'localhost'
19
+LOGPORT = 19996
26 20
 
27
-loggers = (
28
-    ('APP', 'DEBUG'),
29
-    (geo.logger_name, 'DEBUG'),
30
-    (socket_protocol.logger_name, 'DEBUG'),
31
-    (state_machine.logger_name, 'DEBUG'),
32
-    (stringtools.logger_name, 'DEBUG'),
33
-    (task.logger_name, 'DEBUG'),
34
-    (tcp_socket.logger_name, 'DEBUG'),
35
-)
36
-formatter = LONG_FMT
21
+formatter = report.LONG_FMT

+ 1
- 1
leyk.py 查看文件

@@ -10,7 +10,7 @@ import time
10 10
 
11 11
 
12 12
 if __name__ == '__main__':
13
-    report.appLoggingConfigure(os.path.dirname(__file__), config.LOG_TARGET, config.loggers)
13
+    report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, ((config.APP_NAME, 'DEBUG'), ), fmt=config.formatter, host=config.LOGHOST, port=config.LOGPORT)
14 14
     s = tcp_socket.tcp_server_stp(config.server_ip, port=config.server_port)
15 15
     prot = protocol.my_server_protocol(s, secret=config.secret)
16 16
     while True:

+ 1
- 1
report

@@ -1 +1 @@
1
-Subproject commit ce174339bc61a57dbb1c152f329d01ec4a5e1040
1
+Subproject commit 25889f225b3593d515e37bebffef21458c961f64

+ 1
- 1
socket_protocol

@@ -1 +1 @@
1
-Subproject commit b0857e4569c34b9b644f5640731be0c413ce54d4
1
+Subproject commit 8a8522d26b486b005f65e7e542742e898f1109e7

+ 1
- 1
state_machine

@@ -1 +1 @@
1
-Subproject commit 362cb1fc1772f8fae4629ebbd8828d5c63689ecd
1
+Subproject commit 561b564b3dc9298936de5b4b51267e56d86ac426

+ 1
- 1
stringtools

@@ -1 +1 @@
1
-Subproject commit d5f9931bcab942ac84d8f09b1559995da0d2676c
1
+Subproject commit 76d8ae9b1bfd894bc5f4b830394ce0552120a508

+ 1
- 1
task

@@ -1 +1 @@
1
-Subproject commit d3fbc5934051ab165723ca37e8f02596329f174a
1
+Subproject commit bbc3c6f93588942087d617e33bc5797041ae2658

+ 1
- 1
tcp_socket

@@ -1 +1 @@
1
-Subproject commit 62f13e2d878b09b81d094c2f77dbd830d72be2c7
1
+Subproject commit 576494b2008b857ed9b6c4bb3f162b5c73cf4b33

正在加载...
取消
保存