|
13 | 13 | from ruamel.yaml import YAML |
14 | 14 |
|
15 | 15 | from fastcs import __version__ |
| 16 | +from fastcs.logging import ( |
| 17 | + GraylogEndpoint, |
| 18 | + GraylogEnvFields, |
| 19 | + GraylogStaticFields, |
| 20 | + LogLevel, |
| 21 | + configure_logging, |
| 22 | + logger, |
| 23 | + parse_graylog_env_fields, |
| 24 | + parse_graylog_static_fields, |
| 25 | +) |
16 | 26 | from fastcs.transport.epics.ca.transport import EpicsCATransport |
17 | 27 | from fastcs.transport.epics.pva.transport import EpicsPVATransport |
18 | 28 | from fastcs.transport.graphql.transport import GraphQLTransport |
@@ -86,6 +96,12 @@ async def serve(self) -> None: |
86 | 96 |
|
87 | 97 | coros.append(self._interactive_shell(context)) |
88 | 98 |
|
| 99 | + logger.info( |
| 100 | + "Starting FastCS", |
| 101 | + controller=self._controller, |
| 102 | + transports=f"[{', '.join(str(t) for t in self._transports)}]", |
| 103 | + ) |
| 104 | + |
89 | 105 | try: |
90 | 106 | await asyncio.gather(*coros) |
91 | 107 | except asyncio.CancelledError: |
@@ -199,10 +215,39 @@ def run( |
199 | 215 | help=f"A yaml file matching the {controller_class.__name__} schema" |
200 | 216 | ), |
201 | 217 | ], |
| 218 | + log_level: Annotated[ |
| 219 | + Optional[LogLevel], # noqa: UP045 |
| 220 | + typer.Option(), |
| 221 | + ] = None, |
| 222 | + graylog_endpoint: Annotated[ |
| 223 | + Optional[GraylogEndpoint], # noqa: UP045 |
| 224 | + typer.Option( |
| 225 | + help="Endpoint for graylog logging - '<host>:<port>'", |
| 226 | + parser=GraylogEndpoint.parse_graylog_endpoint, |
| 227 | + ), |
| 228 | + ] = None, |
| 229 | + graylog_static_fields: Annotated[ |
| 230 | + Optional[GraylogStaticFields], # noqa: UP045 |
| 231 | + typer.Option( |
| 232 | + help="Fields to add to graylog messages with static values", |
| 233 | + parser=parse_graylog_static_fields, |
| 234 | + ), |
| 235 | + ] = None, |
| 236 | + graylog_env_fields: Annotated[ |
| 237 | + Optional[GraylogEnvFields], # noqa: UP045 |
| 238 | + typer.Option( |
| 239 | + help="Fields to add to graylog messages from environment variables", |
| 240 | + parser=parse_graylog_env_fields, |
| 241 | + ), |
| 242 | + ] = None, |
202 | 243 | ): |
203 | 244 | """ |
204 | 245 | Start the controller |
205 | 246 | """ |
| 247 | + configure_logging( |
| 248 | + log_level, graylog_endpoint, graylog_static_fields, graylog_env_fields |
| 249 | + ) |
| 250 | + |
206 | 251 | controller_class = ctx.obj.controller_class |
207 | 252 | fastcs_options = ctx.obj.fastcs_options |
208 | 253 |
|
|
0 commit comments