Skip to content

Commit dc6f444

Browse files
author
Dilyan Marinov
committed
vdk-structlog: add default logging format values
Why? There should be separate default configs for local and cloud runs What? Refactor structlog plugin to eliminate repeating code Remove syslog config tests Fix bug with vdk fields crashing logging for custom format Add tests for vdk fields with custom format Add default logging config to the data job base image Note: The default config will not have effect unless vdk-structlog is installed How was this tested? Functional tests CI What kind of change is this? Feature/non-breaking Signed-off-by: Dilyan Marinov <mdilyan@vmware.com>
1 parent 59d2a85 commit dc6f444

File tree

6 files changed

+182
-278
lines changed

6 files changed

+182
-278
lines changed

projects/control-service/projects/job-base-image/Dockerfile-data-job-base

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ WORKDIR /job
1111
# Install native dependencies so that requirements in requirements.txt can be installed
1212
# some (like openssl) should be pre-installed in the base image but let's be explicit
1313
RUN set -ex \
14-
&& apt-get update \
15-
&& apt-get -y install --no-install-recommends \
16-
build-essential openssl g++
14+
&& apt-get update \
15+
&& apt-get -y install --no-install-recommends \
16+
build-essential openssl g++
1717

1818
# Install the native dependencies necessary for cx_Oracle python library
1919
# See https://oracle.github.io/odpi/doc/installation.html#linux
@@ -27,6 +27,11 @@ RUN set -ex \
2727
&& ldconfig \
2828
&& apt-get purge -y --auto-remove curl unzip
2929

30+
# Setup default logging with vdk-structlog
31+
ENV VDK_STRUCTLOG_FORMAT="console"
32+
ENV VDK_STRUCTLOG_CONSOLE_CUSTOM_FORMAT="%(asctime)s [VDK] %(vdk_job_name)s [%(levelname)-5.5s] %(name)-30.30s %(filename)20.20s:%(lineno)-4.4s %(funcName)-16.16s[id:%(attempt_id)s] - %(message)s"
33+
34+
3035
# libaio1 - LGPL-2.1+ https://developer.puri.sm/licenses/Librem5/Birch/libaio1/copyright
3136
# curl - MIT/X* modified https://curl.se/docs/copyright.html
3237
# unzip - MIT https://github.com/vipsoft/Unzip/blob/master/LICENSE

projects/vdk-plugins/vdk-structlog/src/vdk/plugin/structlog/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
STRUCTLOG_LOGGING_FORMAT_DEFAULT = "console"
1212

1313
STRUCTLOG_LOGGING_METADATA_JOB = {
14+
"attempt_id": "%(attempt_id)s",
1415
"vdk_job_name": "%(vdk_job_name)s",
1516
"vdk_step_name": "%(vdk_step_name)s",
1617
"vdk_step_type": "%(vdk_step_type)s",
@@ -44,6 +45,7 @@
4445
}
4546

4647
CONSOLE_STRUCTLOG_LOGGING_METADATA_JOB = {
48+
"attempt_id": "[id:%(attempt_id)s]",
4749
"vdk_job_name": "%(vdk_job_name)s",
4850
"vdk_step_name": "%(vdk_step_name)s",
4951
"vdk_step_type": "%(vdk_step_type)s",

0 commit comments

Comments
 (0)