Skip to content

Conversation

@cognifloyd
Copy link
Member

This PR has commits cherry-picked from #6202

I'm working towards getting pants to run our tests via pytest. While running unit tests, I found that the logging.conf files depend on python code, but pants cannot infer dependencies in conf files.

For example, this logging.conf snippet uses 3 classes from st2common.logging.formatters:

[formatter_simpleConsoleFormatter]
class=st2common.logging.formatters.ConsoleLogFormatter
format=%(asctime)s %(levelname)s [-] %(message)s
datefmt=
[formatter_verboseConsoleFormatter]
class=st2common.logging.formatters.ConsoleLogFormatter
format=%(asctime)s %(thread)s %(levelname)s %(module)s [-] %(message)s
datefmt=
[formatter_gelfFormatter]
class=st2common.logging.formatters.GelfLogFormatter
format=%(message)s

And this snippet uses st2common.log.ConfigurableSyslogHandler:

[handler_syslogHandler]
class=st2common.log.ConfigurableSyslogHandler
level=DEBUG
formatter=syslogVerboseFormatter
args=()

Recording these dependencies for every conf file would be very repetitive, though, so I added 3 pants macros to simplify defining the dependencies in BUILD metadata:

  • st2_logging_conf_file
  • st2_logging_conf_files
  • st2_logging_conf_resources

@cognifloyd cognifloyd added this to the pants milestone Sep 25, 2024
@cognifloyd cognifloyd self-assigned this Sep 25, 2024
@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Sep 25, 2024
@cognifloyd cognifloyd requested a review from a team September 25, 2024 15:12
@cognifloyd cognifloyd merged commit 3e952e7 into master Sep 25, 2024
@cognifloyd cognifloyd deleted the pants-logging-conf-macros branch September 25, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure: ci/cd pantsbuild size/M PR that changes 30-99 lines. Good size to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants