Commit 12451fdec7cfbf281418971e2bf273a6eef85913

Authored by Etienne Pallier
1 parent 7f6e4bdc
Exists in dev

Amélioration logging

	- ajout quelques log debug dans AgentM
	- script PYROS_DOCKER_RUN démarre le serveur web et l'agentM en mode
debug
1 1
2 2
3 -05-01-2022 (EP) : 3 +05-01-2022 (EP) : v0.3.1.2
  4 + - ajout quelques log debug dans AgentM
  5 + - script PYROS_DOCKER_RUN démarre le serveur web et l'agentM en mode debug
  6 +
  7 +05-01-2022 (EP) : v0.3.1.1
4 - log agents : 1 dossier par agent 8 - log agents : 1 dossier par agent
5 - log.info => format simplifié = print() 9 - log.info => format simplifié = print()
6 10
7 -05-01-2022 (EP) : 11 +05-01-2022 (EP) : v0.3.1.0
8 - New pyros logger : src/pyros_logger.py 12 - New pyros logger : src/pyros_logger.py
9 13
10 -08-12-2021 (EP) : 14 +08-12-2021 (EP) : v0.3.0.0
11 - new PYROS_.py script, wrapper on pyros.py 15 - new PYROS_.py script, wrapper on pyros.py
12 - added this CHANGELOG file 16 - added this CHANGELOG file
docker/PYROS_DOCKER_RUN
@@ -13,8 +13,9 @@ echo "LOG files :" @@ -13,8 +13,9 @@ echo "LOG files :"
13 # - Display log on current terminal 13 # - Display log on current terminal
14 #docker exec -it pyros python3 pyros.py start webserver $@ 14 #docker exec -it pyros python3 pyros.py start webserver $@
15 # - Save log in file 15 # - Save log in file
  16 +docker exec pyros python3 pyros.py -d start -o guitalens webserver >> ../../LOG_PYROS_webserver.log 2>&1 &
16 #docker exec pyros python3 pyros.py start webserver $@ > ../../LOG_PYROS_webserver.log 2>&1 & 17 #docker exec pyros python3 pyros.py start webserver $@ > ../../LOG_PYROS_webserver.log 2>&1 &
17 -docker exec pyros python3 pyros.py start -o tnc webserver >> ../../LOG_PYROS_webserver.log 2>&1 & 18 +#docker exec pyros python3 pyros.py start -o tnc webserver >> ../../LOG_PYROS_webserver.log 2>&1 &
18 echo "- Webserver LOG file is ../../LOG_PYROS_webserver.log" 19 echo "- Webserver LOG file is ../../LOG_PYROS_webserver.log"
19 20
20 # exit if webserver only 21 # exit if webserver only
@@ -34,7 +35,7 @@ echo "- PLC simulator LOG file is ../../LOG_PYROS_plc_simulator.log" @@ -34,7 +35,7 @@ echo "- PLC simulator LOG file is ../../LOG_PYROS_plc_simulator.log"
34 # - Display log on current terminal 35 # - Display log on current terminal
35 #docker exec -it pyros python3 pyros.py start agentM 36 #docker exec -it pyros python3 pyros.py start agentM
36 # - Save log in file 37 # - Save log in file
37 -docker exec pyros python3 pyros.py start agentM -o "guitalens" >> ../../LOG_PYROS_agent_monitoring.log 2>&1 & 38 +docker exec pyros python3 pyros.py -d start agentM -o "guitalens" >> ../../LOG_PYROS_agent_monitoring.log 2>&1 &
38 echo "- Agent Monitoring LOG file is ../../LOG_PYROS_agent_monitoring.log" 39 echo "- Agent Monitoring LOG file is ../../LOG_PYROS_agent_monitoring.log"
39 40
40 fi 41 fi
src/core/pyros_django/monitoring/AgentM.py
@@ -10,7 +10,7 @@ import sys @@ -10,7 +10,7 @@ import sys
10 10
11 sys.path.append("..") 11 sys.path.append("..")
12 sys.path.append("../../../..") 12 sys.path.append("../../../..")
13 -from src.core.pyros_django.agent.Agent import Agent, build_agent 13 +from src.core.pyros_django.agent.Agent import Agent, build_agent, log
14 14
15 # PM 20190416 recycle code 15 # PM 20190416 recycle code
16 from src.core.pyros_django.devices.PLC import PLCController 16 from src.core.pyros_django.devices.PLC import PLCController
@@ -40,6 +40,9 @@ class AgentM(Agent): @@ -40,6 +40,9 @@ class AgentM(Agent):
40 print ("AGENT ENV: config PLC is (ip={}, port={})".format(plcController.ip, plcController.port)) 40 print ("AGENT ENV: config PLC is (ip={}, port={})".format(plcController.ip, plcController.port))
41 plc_checker = PlcChecker() 41 plc_checker = PlcChecker()
42 42
  43 + log.debug("PLC instanciated")
  44 +
  45 +
43 46
44 ''' 47 '''
45 # Who should I send commands to ? 48 # Who should I send commands to ?
@@ -72,6 +75,7 @@ class AgentM(Agent): @@ -72,6 +75,7 @@ class AgentM(Agent):
72 # @override 75 # @override
73 def init(self): 76 def init(self):
74 super().init() 77 super().init()
  78 + log.debug("end init()")
75 # --- Set the mode according the startmode value 79 # --- Set the mode according the startmode value
76 ##agent_alias = self.__class__.__name__ 80 ##agent_alias = self.__class__.__name__
77 ##self.set_mode_from_config(agent_alias) 81 ##self.set_mode_from_config(agent_alias)
@@ -150,6 +154,7 @@ class AgentM(Agent): @@ -150,6 +154,7 @@ class AgentM(Agent):
150 # Note : in Agent.py, routine_process_body seems to be the main function of routine of the agent 154 # Note : in Agent.py, routine_process_body seems to be the main function of routine of the agent
151 # We need to override routine_process_body and not routine_process 155 # We need to override routine_process_body and not routine_process
152 def routine_process_body(self): 156 def routine_process_body(self):
  157 + log.debug("in routine_process_body()")
153 print("TODO: we recycle code") 158 print("TODO: we recycle code")
154 status_plc = self.plcController.getStatus() 159 status_plc = self.plcController.getStatus()
155 if self.parseNewStatus(status_plc): 160 if self.parseNewStatus(status_plc):
@@ -170,6 +175,8 @@ class AgentM(Agent): @@ -170,6 +175,8 @@ class AgentM(Agent):
170 outside.setAttribute(sensor, value) 175 outside.setAttribute(sensor, value)
171 outside.setGlobalStatus() 176 outside.setGlobalStatus()
172 outside.save() 177 outside.save()
  178 + log.debug("saved weather")
  179 +
173 180
174 # @override 181 # @override
175 def thread_exec_specific_cmd_main(self): 182 def thread_exec_specific_cmd_main(self):
src/core/pyros_django/pyros/settings.py
@@ -404,6 +404,6 @@ python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '. @@ -404,6 +404,6 @@ python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '.
404 python_version = python_version.stdout 404 python_version = python_version.stdout
405 today = "2021-11-09" 405 today = "2021-11-09"
406 django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1] 406 django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1]
407 -pyros_version = "0.3.1.1" 407 +pyros_version = "0.3.1.2"
408 #pyros_version = "0.2.12.0" 408 #pyros_version = "0.2.12.0"
409 VERSION_NUMBER = f"{pyros_version}_{django_version_major}.{django_version_minor}_{python_version}_{today}" 409 VERSION_NUMBER = f"{pyros_version}_{django_version_major}.{django_version_minor}_{python_version}_{today}"