diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b26bf27..599ed84 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -70,14 +70,13 @@ jobs: run: | pytest - - name: Gather Badge Data - if: github.ref_name == 'main' && github.event_name == 'push' + - name: coverage | Test Coverage run: | coverage run -m pytest -s coverage report -m - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3 - if: always() && github.ref_name == 'main' && github.event_name == 'push' + if: github.ref_name == 'main' && github.event_name == 'push' with: ref: assets path: assets diff --git a/slack_logger/__init__.py b/slack_logger/__init__.py index b222aa0..bd2ca49 100644 --- a/slack_logger/__init__.py +++ b/slack_logger/__init__.py @@ -81,13 +81,16 @@ def construct_context( if config.context != []: context_msg = ", ".join(config.context) return ContextBlock(elements=[MarkdownTextObject(text=context_msg)]) - elif env is not None and service is not None: - return ContextBlock(elements=[MarkdownTextObject(text=f":point_right: {env}, {service}")]) - elif env is None: - return ContextBlock(elements=[MarkdownTextObject(text=f":point_right: {env}")]) - elif service is None: - return ContextBlock(elements=[MarkdownTextObject(text=f":point_right: {service}")]) - return None + if env is None and service is None: + return None + + context: List[str] = [] + if env is not None: + context.append(env) + if service is not None: + context.append(service) + + return ContextBlock(elements=[MarkdownTextObject(text=f":point_right: {','.join(context)}")]) def format(self, record: LogRecord) -> str: maybe_blocks: Sequence[Optional[Block]] = self.format_blocks(record=record)