summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-logjson.spec292
-rw-r--r--sources1
3 files changed, 294 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..2b6e2f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/logjson-2020.3.1.tar.gz
diff --git a/python-logjson.spec b/python-logjson.spec
new file mode 100644
index 0000000..3ed5ac7
--- /dev/null
+++ b/python-logjson.spec
@@ -0,0 +1,292 @@
+%global _empty_manifest_terminate_build 0
+Name: python-logjson
+Version: 2020.3.1
+Release: 1
+Summary: logjson
+License: Apache Software License
+URL: https://github.com/cjrh/logjson
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ec/75/92aa98289d5f058d111fd61e87ed417d02939c5f35f507dcbd0178244be3/logjson-2020.3.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-typing
+Requires: python3-pytest
+Requires: python3-pytest-cov
+Requires: python3-wheel
+
+%description
+**Goal**: easily generate structured JSON logging.
+`logstash <https://www.elastic.co/products/logstash>`_ mode is optional.
+ import logging
+ import logjson
+ logger = logging.getLogger('blah')
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logjson.JSONFormatter(pretty=True)
+ )
+ logger.addHandler(handler)
+ logger.info('hi %s %s!', 'you', 'there')
+Output:
+ {
+ "name": "blah",
+ "msg": "hi %s %s!",
+ "args": [
+ "you",
+ "there"
+ ],
+ "levelname": "INFO",
+ "levelno": 20,
+ "pathname": "<snip>",
+ "filename": "test_main.py",
+ "module": "test_main",
+ "exc_text": null,
+ "stack_info": null,
+ "lineno": 17,
+ "funcName": "test_main",
+ "created": 1511750128.6285746,
+ "msecs": 628.5746097564697,
+ "relativeCreated": 23.08201789855957,
+ "thread": 139929130264384,
+ "threadName": "MainThread",
+ "processName": "MainProcess",
+ "process": 18460,
+ "message": "hi you there!",
+ "created_iso": "2017-11-27T02:35:28.628575+00:00"
+ }
+Logstash mode is only one param away:
+ logger = logging.getLogger('ls')
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logjson.JSONFormatter(pretty=True, logstash_mode=True)
+ )
+ logger.addHandler(handler)
+ logger.info('logstash test')
+Output:
+ {
+ "@message": "logstash test",
+ "@source_host": "localhost.localdomain",
+ "@timestamp": "2017-11-27T02:35:28.631275+00:00",
+ "@fields": {
+ "name": "ls",
+ "msg": "logstash test",
+ "args": [],
+ "levelname": "INFO",
+ "levelno": 20,
+ "pathname": "<snip>",
+ "filename": "test_main.py",
+ "module": "test_main",
+ "exc_text": null,
+ "stack_info": null,
+ "lineno": 42,
+ "funcName": "test_logstash",
+ "created": 1511750128.631275,
+ "msecs": 631.274938583374,
+ "relativeCreated": 25.782346725463867,
+ "thread": 139929130264384,
+ "threadName": "MainThread",
+ "processName": "MainProcess",
+ "process": 18460
+ }
+ }
+
+%package -n python3-logjson
+Summary: logjson
+Provides: python-logjson
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-logjson
+**Goal**: easily generate structured JSON logging.
+`logstash <https://www.elastic.co/products/logstash>`_ mode is optional.
+ import logging
+ import logjson
+ logger = logging.getLogger('blah')
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logjson.JSONFormatter(pretty=True)
+ )
+ logger.addHandler(handler)
+ logger.info('hi %s %s!', 'you', 'there')
+Output:
+ {
+ "name": "blah",
+ "msg": "hi %s %s!",
+ "args": [
+ "you",
+ "there"
+ ],
+ "levelname": "INFO",
+ "levelno": 20,
+ "pathname": "<snip>",
+ "filename": "test_main.py",
+ "module": "test_main",
+ "exc_text": null,
+ "stack_info": null,
+ "lineno": 17,
+ "funcName": "test_main",
+ "created": 1511750128.6285746,
+ "msecs": 628.5746097564697,
+ "relativeCreated": 23.08201789855957,
+ "thread": 139929130264384,
+ "threadName": "MainThread",
+ "processName": "MainProcess",
+ "process": 18460,
+ "message": "hi you there!",
+ "created_iso": "2017-11-27T02:35:28.628575+00:00"
+ }
+Logstash mode is only one param away:
+ logger = logging.getLogger('ls')
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logjson.JSONFormatter(pretty=True, logstash_mode=True)
+ )
+ logger.addHandler(handler)
+ logger.info('logstash test')
+Output:
+ {
+ "@message": "logstash test",
+ "@source_host": "localhost.localdomain",
+ "@timestamp": "2017-11-27T02:35:28.631275+00:00",
+ "@fields": {
+ "name": "ls",
+ "msg": "logstash test",
+ "args": [],
+ "levelname": "INFO",
+ "levelno": 20,
+ "pathname": "<snip>",
+ "filename": "test_main.py",
+ "module": "test_main",
+ "exc_text": null,
+ "stack_info": null,
+ "lineno": 42,
+ "funcName": "test_logstash",
+ "created": 1511750128.631275,
+ "msecs": 631.274938583374,
+ "relativeCreated": 25.782346725463867,
+ "thread": 139929130264384,
+ "threadName": "MainThread",
+ "processName": "MainProcess",
+ "process": 18460
+ }
+ }
+
+%package help
+Summary: Development documents and examples for logjson
+Provides: python3-logjson-doc
+%description help
+**Goal**: easily generate structured JSON logging.
+`logstash <https://www.elastic.co/products/logstash>`_ mode is optional.
+ import logging
+ import logjson
+ logger = logging.getLogger('blah')
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logjson.JSONFormatter(pretty=True)
+ )
+ logger.addHandler(handler)
+ logger.info('hi %s %s!', 'you', 'there')
+Output:
+ {
+ "name": "blah",
+ "msg": "hi %s %s!",
+ "args": [
+ "you",
+ "there"
+ ],
+ "levelname": "INFO",
+ "levelno": 20,
+ "pathname": "<snip>",
+ "filename": "test_main.py",
+ "module": "test_main",
+ "exc_text": null,
+ "stack_info": null,
+ "lineno": 17,
+ "funcName": "test_main",
+ "created": 1511750128.6285746,
+ "msecs": 628.5746097564697,
+ "relativeCreated": 23.08201789855957,
+ "thread": 139929130264384,
+ "threadName": "MainThread",
+ "processName": "MainProcess",
+ "process": 18460,
+ "message": "hi you there!",
+ "created_iso": "2017-11-27T02:35:28.628575+00:00"
+ }
+Logstash mode is only one param away:
+ logger = logging.getLogger('ls')
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logjson.JSONFormatter(pretty=True, logstash_mode=True)
+ )
+ logger.addHandler(handler)
+ logger.info('logstash test')
+Output:
+ {
+ "@message": "logstash test",
+ "@source_host": "localhost.localdomain",
+ "@timestamp": "2017-11-27T02:35:28.631275+00:00",
+ "@fields": {
+ "name": "ls",
+ "msg": "logstash test",
+ "args": [],
+ "levelname": "INFO",
+ "levelno": 20,
+ "pathname": "<snip>",
+ "filename": "test_main.py",
+ "module": "test_main",
+ "exc_text": null,
+ "stack_info": null,
+ "lineno": 42,
+ "funcName": "test_logstash",
+ "created": 1511750128.631275,
+ "msecs": 631.274938583374,
+ "relativeCreated": 25.782346725463867,
+ "thread": 139929130264384,
+ "threadName": "MainThread",
+ "processName": "MainProcess",
+ "process": 18460
+ }
+ }
+
+%prep
+%autosetup -n logjson-2020.3.1
+
+%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-logjson -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 2020.3.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..37aa8e6
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+fafe58a7bff0faa47c0e3fb9a696beb2 logjson-2020.3.1.tar.gz