|
9 | 9 | import argparse |
10 | 10 |
|
11 | 11 |
|
12 | | -logging.basicConfig(level=logging.INFO) |
13 | | -#put log into file as well as console |
14 | | -# Create a custom logger |
15 | | -logger = logging.getLogger('my_logger') |
16 | | -logger.setLevel(logging.DEBUG) # Set the minimum logging level |
17 | | - |
18 | | -# Create handlers: one for console, one for file |
19 | | -console_handler = logging.StreamHandler() |
20 | | -file_handler = logging.FileHandler('logfile.log') |
21 | | - |
22 | | -# Set logging level for each handler |
23 | | -console_handler.setLevel(logging.ERROR) |
24 | | -file_handler.setLevel(logging.INFO) |
25 | | - |
26 | | -# Add the handlers to the logger |
27 | | -logger.addHandler(console_handler) |
28 | | -logger.addHandler(file_handler) |
| 12 | +logging.basicConfig(level=logging.DEBUG) |
29 | 13 |
|
30 | 14 | class GrpcAgent: |
31 | 15 | def __init__(self, agent_type, uniform_number) -> None: |
@@ -162,11 +146,11 @@ def SendByeCommand(self, register_response: pb2.RegisterResponse, context): |
162 | 146 | return res |
163 | 147 |
|
164 | 148 | def GetBestPlannerAction(self, pairs: pb2.BestPlannerActionRequest, context): |
165 | | - logger.debug(f"GetBestPlannerAction cycle:{pairs.state.world_model.cycle} pairs:{len(pairs.pairs)} unum:{pairs.state.register_response.uniform_number}") |
| 149 | + logging.debug(f"GetBestPlannerAction cycle:{pairs.state.world_model.cycle} pairs:{len(pairs.pairs)} unum:{pairs.state.register_response.uniform_number}") |
166 | 150 | pairs_list: list[int, pb2.RpcActionState] = [(k, v) for k, v in pairs.pairs.items()] |
167 | 151 | pairs_list.sort(key=lambda x: x[0]) |
168 | 152 | best_action = max(pairs_list, key=lambda x: -1000 if x[1].action.parent_index != -1 else x[1].predict_state.ball_position.x) |
169 | | - logger.debug(f"Best action: {best_action[0]} {best_action[1].action.description} to {best_action[1].action.target_unum} in ({round(best_action[1].action.target_point.x, 2)},{round(best_action[1].action.target_point.y, 2)}) e:{round(best_action[1].evaluation,2)}") |
| 153 | + logging.debug(f"Best action: {best_action[0]} {best_action[1].action.description} to {best_action[1].action.target_unum} in ({round(best_action[1].action.target_point.x, 2)},{round(best_action[1].action.target_point.y, 2)}) e:{round(best_action[1].evaluation,2)}") |
170 | 154 | res = pb2.BestPlannerActionResponse(index=best_action[0]) |
171 | 155 | return res |
172 | 156 |
|
|
0 commit comments