You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am developing the fluent-logger-python in AWS Lambda and I would like to pass the lambda context to fluent by using the custom_fomat. However, it seems the fluent-logger-python doesn't allow me to do it.
For the workaround, I pass the function_name only to the custom_format as a string first. But I would like to advise how to pass the entire context JSON to the custom_format.
Response:
{
"errorMessage": "'LambdaContext' object has no attribute 'find'",
"errorType": "AttributeError",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 28, in lambda_handler\n log.info(\"This log entry will be logged2.\")\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 1434, in info\n self._log(INFO, msg, args, **kwargs)\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 1577, in _log\n self.handle(record)\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 1587, in handle\n self.callHandlers(record)\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 1649, in callHandlers\n hdlr.handle(record)\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 950, in handle\n self.emit(record)\n",
" File \"/opt/python/lib/python3.8/site-packages/fluent/handler.py\", line 237, in emit\n data = self.format(record)\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 925, in format\n return fmt.format(record)\n",
" File \"/opt/python/lib/python3.8/site-packages/fluent/handler.py\", line 97, in format\n super(FluentRecordFormatter, self).format(record)\n",
" File \"/var/lang/lib/python3.8/logging/__init__.py\", line 665, in format\n if self.usesTime():\n",
" File \"/opt/python/lib/python3.8/site-packages/fluent/handler.py\", line 169, in _format_by_dict_uses_time\n return any([value.find(search) >= 0 for value in self._fmt_dict.values()])\n",
" File \"/opt/python/lib/python3.8/site-packages/fluent/handler.py\", line 169, in <listcomp>\n return any([value.find(search) >= 0 for value in self._fmt_dict.values()])\n"
]
}
Please advise. Thank you very much!
The text was updated successfully, but these errors were encountered:
chikinchoi
changed the title
Cannot pass lambda context(JSON) to custom_fomatter
Cannot pass lambda context(JSON) to custom_fomat
Sep 2, 2020
You can't pass arbitrary objects to format. If you're logging JSON you're logging JSON as logger.log({'a': 1, 'b': 2}) but the object also needs to be formattable to begin with, which I doubt Lambda context is. Same with function name. https://docs.python.org/3/library/logging.html#formatter-objects
Hi,
I am developing the fluent-logger-python in AWS Lambda and I would like to pass the lambda context to fluent by using the custom_fomat. However, it seems the fluent-logger-python doesn't allow me to do it.
For the workaround, I pass the function_name only to the custom_format as a string first. But I would like to advise how to pass the entire context JSON to the custom_format.
Below is my lambda code:
Error Response:
Please advise. Thank you very much!
The text was updated successfully, but these errors were encountered: