Skip to content

Commit 2d077d7

Browse files
authored
Merge pull request #549 from cybertec-postgresql/548-disable-database-logging
[+] allow database logging disabling, closes #548
2 parents d57344d + 1e07f01 commit 2d077d7

File tree

6 files changed

+53
-43
lines changed

6 files changed

+53
-43
lines changed

docs/README.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,42 +56,42 @@ Command line options
5656
# ./pg_timetable
5757
5858
Application Options:
59-
-c, --clientname= Unique name for application instance [$PGTT_CLIENTNAME]
60-
--config= YAML configuration file
61-
--no-program-tasks Disable executing of PROGRAM tasks [$PGTT_NOPROGRAMTASKS]
59+
-c, --clientname= Unique name for application instance [$PGTT_CLIENTNAME]
60+
--config= YAML configuration file
61+
--no-program-tasks Disable executing of PROGRAM tasks [$PGTT_NOPROGRAMTASKS]
6262
6363
Connection:
64-
-h, --host= PostgreSQL host (default: localhost) [$PGTT_PGHOST]
65-
-p, --port= PostgreSQL port (default: 5432) [$PGTT_PGPORT]
66-
-d, --dbname= PostgreSQL database name (default: timetable) [$PGTT_PGDATABASE]
67-
-u, --user= PostgreSQL user (default: scheduler) [$PGTT_PGUSER]
68-
--password= PostgreSQL user password [$PGTT_PGPASSWORD]
69-
--sslmode=[disable|require] What SSL mode to use for connection (default: disable) [$PGTT_PGSSLMODE]
70-
--pgurl= PostgreSQL connection URL [$PGTT_URL]
71-
--timeout= PostgreSQL connection timeout in seconds (default: 90) [$PGTT_TIMEOUT]
64+
-h, --host= PostgreSQL host (default: localhost) [$PGTT_PGHOST]
65+
-p, --port= PostgreSQL port (default: 5432) [$PGTT_PGPORT]
66+
-d, --dbname= PostgreSQL database name (default: timetable) [$PGTT_PGDATABASE]
67+
-u, --user= PostgreSQL user (default: scheduler) [$PGTT_PGUSER]
68+
--password= PostgreSQL user password [$PGTT_PGPASSWORD]
69+
--sslmode=[disable|require] What SSL mode to use for connection (default: disable) [$PGTT_PGSSLMODE]
70+
--pgurl= PostgreSQL connection URL [$PGTT_URL]
71+
--timeout= PostgreSQL connection timeout in seconds (default: 90) [$PGTT_TIMEOUT]
7272
7373
Logging:
74-
--log-level=[debug|info|error] Verbosity level for stdout and log file (default: info)
75-
--log-database-level=[debug|info|error] Verbosity level for database storing (default: info)
76-
--log-file= File name to store logs
77-
--log-file-format=[json|text] Format of file logs (default: json)
74+
--log-level=[debug|info|error] Verbosity level for stdout and log file (default: info)
75+
--log-database-level=[debug|info|error|none] Verbosity level for database storing (default: info)
76+
--log-file= File name to store logs
77+
--log-file-format=[json|text] Format of file logs (default: json)
7878
7979
Start:
80-
-f, --file= SQL script file to execute during startup
81-
--init Initialize database schema to the latest version and exit. Can be used
82-
with --upgrade
83-
--upgrade Upgrade database to the latest version
84-
--debug Run in debug mode. Only asynchronous chains will be executed
80+
-f, --file= SQL script file to execute during startup
81+
--init Initialize database schema to the latest version and exit. Can be used
82+
with --upgrade
83+
--upgrade Upgrade database to the latest version
84+
--debug Run in debug mode. Only asynchronous chains will be executed
8585
8686
Resource:
87-
--cron-workers= Number of parallel workers for scheduled chains (default: 16)
88-
--interval-workers= Number of parallel workers for interval chains (default: 16)
89-
--chain-timeout= Abort any chain that takes more than the specified number of milliseconds
90-
--task-timeout= Abort any task within a chain that takes more than the specified number
91-
of milliseconds
87+
--cron-workers= Number of parallel workers for scheduled chains (default: 16)
88+
--interval-workers= Number of parallel workers for interval chains (default: 16)
89+
--chain-timeout= Abort any chain that takes more than the specified number of milliseconds
90+
--task-timeout= Abort any task within a chain that takes more than the specified number
91+
of milliseconds
9292
9393
REST:
94-
--rest-port: REST API port (default: 0) [%PGTT_RESTPORT%]
94+
--rest-port= REST API port (default: 0) [%PGTT_RESTPORT%]
9595
9696
9797
Contributing

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ require (
2424
github.com/jackc/puddle/v2 v2.2.0 // indirect
2525
github.com/magiconair/properties v1.8.7 // indirect
2626
github.com/mitchellh/mapstructure v1.5.0 // indirect
27-
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
27+
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
2828
github.com/pkg/errors v0.9.1 // indirect
2929
github.com/pmezard/go-difflib v1.0.0 // indirect
30-
github.com/spf13/afero v1.9.4 // indirect
30+
github.com/spf13/afero v1.9.5 // indirect
3131
github.com/spf13/cast v1.5.0 // indirect
3232
github.com/spf13/jwalterweatherman v1.1.0 // indirect
3333
github.com/spf13/pflag v1.0.5 // indirect
3434
github.com/subosito/gotenv v1.4.2 // indirect
35-
golang.org/x/crypto v0.6.0 // indirect
35+
golang.org/x/crypto v0.7.0 // indirect
3636
golang.org/x/sync v0.1.0 // indirect
37-
golang.org/x/sys v0.5.0 // indirect
38-
golang.org/x/text v0.7.0 // indirect
37+
golang.org/x/sys v0.6.0 // indirect
38+
golang.org/x/text v0.8.0 // indirect
3939
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
4040
gopkg.in/ini.v1 v1.67.0 // indirect
4141
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ github.com/ory/mail/v3 v3.0.1-0.20210418065910-7f033ddea8dc h1:BU12v9x5hvONtYU2R
151151
github.com/ory/mail/v3 v3.0.1-0.20210418065910-7f033ddea8dc/go.mod h1:vAPEMm1zIQKGmM9hcZTSlOU/CDVCXHGOw6SFxPlSoHw=
152152
github.com/pashagolub/pgxmock/v2 v2.5.0 h1:Lb313sVqXuiGcvtbHt2QVuVTYLHMzmquDiBeVquwrkc=
153153
github.com/pashagolub/pgxmock/v2 v2.5.0/go.mod h1:FsT+LxxrLNqeRWHzk2SBrSW+5m+kXLcKoVZxigHVHeI=
154-
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
155-
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
154+
github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us=
155+
github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
156156
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
157157
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
158158
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
@@ -167,8 +167,8 @@ github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08O
167167
github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw=
168168
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
169169
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
170-
github.com/spf13/afero v1.9.4 h1:Sd43wM1IWz/s1aVXdOBkjJvuP8UdyqioeE4AmM0QsBs=
171-
github.com/spf13/afero v1.9.4/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
170+
github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
171+
github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
172172
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
173173
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
174174
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
@@ -208,9 +208,9 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
208208
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
209209
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
210210
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
211-
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
212-
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
213-
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
211+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
212+
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
213+
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
214214
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
215215
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
216216
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -275,6 +275,7 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY
275275
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
276276
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
277277
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
278+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
278279
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
279280
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
280281
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -329,21 +330,24 @@ golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7w
329330
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
330331
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
331332
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
333+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
332334
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
333335
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
334336
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
335337
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
336-
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
337-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
338+
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
339+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
338340
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
339341
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
340342
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
341343
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
342344
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
343345
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
344346
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
345-
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
346-
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
347+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
348+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
349+
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
350+
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
347351
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
348352
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
349353
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

internal/config/cmdparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ConnectionOpts struct {
2222
// LoggingOpts specifies the logging configuration
2323
type LoggingOpts struct {
2424
LogLevel string `long:"log-level" mapstructure:"log-level" description:"Verbosity level for stdout and log file" choice:"debug" choice:"info" choice:"error" default:"info"`
25-
LogDBLevel string `long:"log-database-level" mapstructure:"log-database-level" description:"Verbosity level for database storing" choice:"debug" choice:"info" choice:"error" default:"info"`
25+
LogDBLevel string `long:"log-database-level" mapstructure:"log-database-level" description:"Verbosity level for database storing" choice:"debug" choice:"info" choice:"error" choice:"none" default:"info"`
2626
LogFile string `long:"log-file" mapstructure:"log-file" description:"File name to store logs"`
2727
LogFileFormat string `long:"log-file-format" mapstructure:"log-file-format" description:"Format of file logs" choice:"json" choice:"text" default:"json"`
2828
}

internal/pgengine/log_hook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ func (hook *LogHook) Fire(entry *logrus.Entry) error {
6464
// Levels returns the available logging levels
6565
func (hook *LogHook) Levels() []logrus.Level {
6666
switch hook.level {
67+
case "none":
68+
return []logrus.Level{}
6769
case "debug":
6870
return logrus.AllLevels
6971
case "info":

internal/pgengine/log_hook_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func TestLogHook(t *testing.T) {
4343
h.level = level
4444
assert.NotEmpty(t, h.Levels())
4545
}
46+
47+
h.level = "none"
48+
assert.Empty(t, h.Levels())
49+
4650
<-time.After(time.Second)
4751
}
4852

0 commit comments

Comments
 (0)