Blame README.md

Packit Service 0a6029
# container-exception-logger
Packit Service 0a6029
A tool designed to run inside of a container which is able to get its input
Packit Service 0a6029
outside of the container.
Packit Service 0a6029
Packit Service 0a6029
This tool was created because there was not possible to get any information
Packit Service 0a6029
outside of a container. The tool is mainly used by interpreter's default hooks
Packit Service 0a6029
to pass unhandled exceptions to a host for further analysis.
Packit Service 0a6029
Packit Service 0a6029
## Format specification
Packit Service 0a6029
It's possible to use whatever format of a message you want.
Packit Service 0a6029
Openshift logging system (fluentd) and ABRT use
Packit Service 0a6029
JSON. For this reason, we recommend using JSON too.
Packit Service 0a6029
Packit Service 0a6029
### Mandatory elements
Packit Service 0a6029
Tools which parse container-exception-logger messages expecting the messages
Packit Service 0a6029
contain following elements:
Packit Service 0a6029
 * `type`: string - exception type - Python, Python3, Ruby, etc.
Packit Service 0a6029
 * `executable`: string - executable which caused the problem
Packit Service 0a6029
 * `reason`: string - reason of the problem
Packit Service 0a6029
 * `backtrace`: string - backtrace of the problem
Packit Service 0a6029
 * `time`: int - seconds since 1970-01-01 00:00:00 UTC
Packit Service 0a6029
Packit Service 0a6029
### Optional elements
Packit Service 0a6029
Additional elements can be added without any limitation. For instance `pid`,
Packit Service 0a6029
`uid`, `msg`, etc.
Packit Service 0a6029
Packit Service 0a6029
Example of a message:
Packit Service 0a6029
```
Packit Service 0a6029
{"type": "Python3", "executable": "/usr/bin/will_python3_raise", "reason": "will_python3_raise:3:<module>:ZeroDivisionError: division by zero", "backtrace": "will_python3_raise:3:<module>:ZeroDivisionError: division by zero\n\nTraceback (most recent call last):\n  File \"/usr/bin/will_python3_raise\", line 3, in <module>\n 0/0\nZeroDivisionError: division by zero\n\nLocal variables in innermost frame:\n__name__: '__main__'\n__doc__: None\n__package__: None\n__loader__: <_frozen_importlib_external.SourceFileLoader object at 0x7fc4568a9780>\n__spec__: None\n__annotations__: {}\n__builtins__: <module 'builtins' (built-in)>\n__file__: '/usr/bin/will_python3_raise'\n__cached__: None\n", "time": 1521454815, "pid": 23}
Packit Service 0a6029
```
Packit Service 0a6029
Packit Service 0a6029
## How to use container-exception-logger
Packit Service 0a6029
**container-exception-logger** - log from a container to a host
Packit Service 0a6029
Packit Service 0a6029
Usage: `container-exception-logger [--no-tag | --tag TAG | --help]`
Packit Service 0a6029
Packit Service 0a6029
**Parameters:**
Packit Service 0a6029
Packit Service 0a6029
`--no-tag` - do not tag a message in logs
Packit Service 0a6029
Packit Service 0a6029
`--tag` - change tag of a message in logs (defaults: 'container-exception-logger')
Packit Service 0a6029
Packit Service 0a6029
**Example of usage:**
Packit Service 0a6029
Packit Service 0a6029
For better illustration variable MSG contains a message from previous capture 'Format specification'.
Packit Service 0a6029
```
Packit Service 0a6029
Container:
Packit Service 0a6029
 $ echo $MSG | container-exception-logger
Packit Service 0a6029
Host's log:
Packit Service 0a6029
 Mar 19 14:59:04 localhost.localdomain dockerd-current[981]: container-exception-logger - $MSG
Packit Service 0a6029
Packit Service 0a6029
Container:
Packit Service 0a6029
 $ echo $MSG | container-exception-logger --no-tag
Packit Service 0a6029
Host's log:
Packit Service 0a6029
 Mar 19 15:00:27 localhost.localdomain dockerd-current[981]: $MSG
Packit Service 0a6029
Packit Service 0a6029
Container:
Packit Service 0a6029
 $ echo $MSG | container-exception-logger --tag new-tag
Packit Service 0a6029
Host's log:
Packit Service 0a6029
 Mar 19 15:00:27 localhost.localdomain dockerd-current[981]: new-tag - $MSG
Packit Service 0a6029
```