Setting Log Handler Formatter

オープン
#189 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

@ericzbeard がすでに取り組んでいます。

2022年10月13日 から。

評価

この issue はまだ評価されていません。

説明

enhancement investigating p2

I'd like to have logs formatted using ecs_logging and noticed adding a handler to my app does nothing to change the log format in the CloudWatch LogGroup.

This for example has no impact to log format:

LOGGER = logging.getLogger(__package__)
LOGGER.setLevel(level=logging.INFO)
handler = logging.StreamHandler()
handler.setFormatter(ecs_logging.StdlibFormatter())
LOGGER.addHandler(handler)

I also tried brute forcing the formatter with no luck:

def set_formatter():
    for logger in logging.root.manager.loggerDict.values():
        if isinstance(logger, logging.PlaceHolder):
            continue

        if logger.hasHandlers():
            for handler in logger.handlers:
                handler.setFormatter(ecs_logging.StdlibFormatter())

@hook.handler(HookInvocationPoint.CREATE_PRE_PROVISION)
def pre_create_handler(
    session: Optional[SessionProxy],
    request: BaseHookHandlerRequest,
    callback_context: MutableMapping[str, Any],
    type_configuration: TypeConfigurationModel,
) -> ProgressEvent:
    set_formatter()
    LOGGER.info(jsonify_hook_context(request=request))
    return ProgressEvent(status=OperationStatus.SUCCESS)

Is there a way to set the format for log output using this library?

主要言語
Python
スター
107
フォーク
46
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws-cloudformation/cloudformation-cli-python-plugin のほかの issue

aws-cloudformation/cloudformation-cli-python-plugin の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。