summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-kubi-ecs-logger.spec343
-rw-r--r--sources1
3 files changed, 345 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..eebef0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/kubi_ecs_logger-0.1.2.tar.gz
diff --git a/python-kubi-ecs-logger.spec b/python-kubi-ecs-logger.spec
new file mode 100644
index 0000000..56243c6
--- /dev/null
+++ b/python-kubi-ecs-logger.spec
@@ -0,0 +1,343 @@
+%global _empty_manifest_terminate_build 0
+Name: python-kubi-ecs-logger
+Version: 0.1.2
+Release: 1
+Summary: Logger based on Elasticsearch Common Schema.
+License: BSD License
+URL: https://pypi.org/project/kubi-ecs-logger/
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/71/7d/10f197320bddb8d1eeff23f15b3b96ce403669a781ed0ac26b833b477bed/kubi_ecs_logger-0.1.2.tar.gz
+BuildArch: noarch
+
+Requires: python3-marshmallow
+
+%description
+<img align="left" src="https://github.com/kumina/kubi_ecs_logger/blob/master/logo.png">
+This Python module makes logging easy for your application.
+The logger outputs JSON formatted logs for ingesting into Elastic.
+
+The module implements the ECS (Elastic Common Schema) specification that
+can be found at for quick reference:
+[ECS Field Reference](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html#ecs-field-reference)
+
+## Install
+You can install the package from PyPi like this:
+```bash
+pip install kubi-ecs-logger
+```
+This package is only for Python 3.6 or newer.
+
+## Usage
+```python
+# Import
+from kubi_ecs_logger import Logger, Severity
+
+# Set some defaults in the start of your app
+# If in development mode the lib will output formatted json.
+Logger().dev = True
+# The minimum level of severity for outputing. E.g. If set to INFO then DEBUG logs will not
+# be printed to standard out
+Logger().severity_output_level = Severity.INFO
+# Set default key/value pairs for the different classes that will always be appended before final output
+Logger().defaults = {
+ "event": {
+ "test": "test value"
+ }
+}
+
+# Log loaded configuration
+Logger().event(
+ category="configuration",
+ action="configuration loaded",
+ dataset="The configuration is loaded from config.yaml"
+).out(severity=Severity.INFO)
+
+# Output
+# {
+# "@timestamp": "2019-07-11T15:11:03.193759+00:00",
+# "event": {
+# "action": "configuration loaded",
+# "category": "configuration",
+# "dataset": "The configuration is loaded from config.yaml",
+# "test": "test value" # From defaults
+# },
+# "logline": {
+# "level": "INFO"
+# }
+# }
+
+# Here is a little bit bigger example
+Logger() \
+ .event(category="requests", action="request received") \
+ .url(path="/test", domain="test.com") \
+ .source(ip="123.251.512.152") \
+ .http_response(status_code=200) \
+ .out(severity=Severity.INFO)
+
+# And here is the output of this one
+# {
+# "@timestamp": "2019-07-11T15:15:48.896921+00:00",
+# "event": {
+# "action": "request received",
+# "category": "requests",
+# "test": "test value" # From defaults
+# },
+# "httpresponse": {
+# "status_code": "200"
+# },
+# "logline": {
+# "level": "INFO"
+# },
+# "source": {
+# "ip": "123.251.512.152"
+# },
+# "url": {
+# "domain": "test.com",
+# "path": "/test"
+# }
+# }
+```
+
+## Dependencies
+| name | version |
+|-------------|---------|
+| marshmallow | 3.15.0 |
+
+
+%package -n python3-kubi-ecs-logger
+Summary: Logger based on Elasticsearch Common Schema.
+Provides: python-kubi-ecs-logger
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-kubi-ecs-logger
+<img align="left" src="https://github.com/kumina/kubi_ecs_logger/blob/master/logo.png">
+This Python module makes logging easy for your application.
+The logger outputs JSON formatted logs for ingesting into Elastic.
+
+The module implements the ECS (Elastic Common Schema) specification that
+can be found at for quick reference:
+[ECS Field Reference](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html#ecs-field-reference)
+
+## Install
+You can install the package from PyPi like this:
+```bash
+pip install kubi-ecs-logger
+```
+This package is only for Python 3.6 or newer.
+
+## Usage
+```python
+# Import
+from kubi_ecs_logger import Logger, Severity
+
+# Set some defaults in the start of your app
+# If in development mode the lib will output formatted json.
+Logger().dev = True
+# The minimum level of severity for outputing. E.g. If set to INFO then DEBUG logs will not
+# be printed to standard out
+Logger().severity_output_level = Severity.INFO
+# Set default key/value pairs for the different classes that will always be appended before final output
+Logger().defaults = {
+ "event": {
+ "test": "test value"
+ }
+}
+
+# Log loaded configuration
+Logger().event(
+ category="configuration",
+ action="configuration loaded",
+ dataset="The configuration is loaded from config.yaml"
+).out(severity=Severity.INFO)
+
+# Output
+# {
+# "@timestamp": "2019-07-11T15:11:03.193759+00:00",
+# "event": {
+# "action": "configuration loaded",
+# "category": "configuration",
+# "dataset": "The configuration is loaded from config.yaml",
+# "test": "test value" # From defaults
+# },
+# "logline": {
+# "level": "INFO"
+# }
+# }
+
+# Here is a little bit bigger example
+Logger() \
+ .event(category="requests", action="request received") \
+ .url(path="/test", domain="test.com") \
+ .source(ip="123.251.512.152") \
+ .http_response(status_code=200) \
+ .out(severity=Severity.INFO)
+
+# And here is the output of this one
+# {
+# "@timestamp": "2019-07-11T15:15:48.896921+00:00",
+# "event": {
+# "action": "request received",
+# "category": "requests",
+# "test": "test value" # From defaults
+# },
+# "httpresponse": {
+# "status_code": "200"
+# },
+# "logline": {
+# "level": "INFO"
+# },
+# "source": {
+# "ip": "123.251.512.152"
+# },
+# "url": {
+# "domain": "test.com",
+# "path": "/test"
+# }
+# }
+```
+
+## Dependencies
+| name | version |
+|-------------|---------|
+| marshmallow | 3.15.0 |
+
+
+%package help
+Summary: Development documents and examples for kubi-ecs-logger
+Provides: python3-kubi-ecs-logger-doc
+%description help
+<img align="left" src="https://github.com/kumina/kubi_ecs_logger/blob/master/logo.png">
+This Python module makes logging easy for your application.
+The logger outputs JSON formatted logs for ingesting into Elastic.
+
+The module implements the ECS (Elastic Common Schema) specification that
+can be found at for quick reference:
+[ECS Field Reference](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html#ecs-field-reference)
+
+## Install
+You can install the package from PyPi like this:
+```bash
+pip install kubi-ecs-logger
+```
+This package is only for Python 3.6 or newer.
+
+## Usage
+```python
+# Import
+from kubi_ecs_logger import Logger, Severity
+
+# Set some defaults in the start of your app
+# If in development mode the lib will output formatted json.
+Logger().dev = True
+# The minimum level of severity for outputing. E.g. If set to INFO then DEBUG logs will not
+# be printed to standard out
+Logger().severity_output_level = Severity.INFO
+# Set default key/value pairs for the different classes that will always be appended before final output
+Logger().defaults = {
+ "event": {
+ "test": "test value"
+ }
+}
+
+# Log loaded configuration
+Logger().event(
+ category="configuration",
+ action="configuration loaded",
+ dataset="The configuration is loaded from config.yaml"
+).out(severity=Severity.INFO)
+
+# Output
+# {
+# "@timestamp": "2019-07-11T15:11:03.193759+00:00",
+# "event": {
+# "action": "configuration loaded",
+# "category": "configuration",
+# "dataset": "The configuration is loaded from config.yaml",
+# "test": "test value" # From defaults
+# },
+# "logline": {
+# "level": "INFO"
+# }
+# }
+
+# Here is a little bit bigger example
+Logger() \
+ .event(category="requests", action="request received") \
+ .url(path="/test", domain="test.com") \
+ .source(ip="123.251.512.152") \
+ .http_response(status_code=200) \
+ .out(severity=Severity.INFO)
+
+# And here is the output of this one
+# {
+# "@timestamp": "2019-07-11T15:15:48.896921+00:00",
+# "event": {
+# "action": "request received",
+# "category": "requests",
+# "test": "test value" # From defaults
+# },
+# "httpresponse": {
+# "status_code": "200"
+# },
+# "logline": {
+# "level": "INFO"
+# },
+# "source": {
+# "ip": "123.251.512.152"
+# },
+# "url": {
+# "domain": "test.com",
+# "path": "/test"
+# }
+# }
+```
+
+## Dependencies
+| name | version |
+|-------------|---------|
+| marshmallow | 3.15.0 |
+
+
+%prep
+%autosetup -n kubi-ecs-logger-0.1.2
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-kubi-ecs-logger -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.2-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..9819037
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+138af6ab35435dc1bd368fa10122072e kubi_ecs_logger-0.1.2.tar.gz