diff options
89 files changed, 372 insertions, 395 deletions
diff --git a/doc/api/config-set.json b/doc/api/config-set.json index a6042f724c..ce0cb4b9ee 100644 --- a/doc/api/config-set.json +++ b/doc/api/config-set.json @@ -8,8 +8,6 @@ \"command\": \"config-set\", \"arguments\": { \"<server>\": { - }, - \"Logging\": { } } }", diff --git a/doc/api/config-test.json b/doc/api/config-test.json index 5bd1f004e5..ea9f12f267 100644 --- a/doc/api/config-test.json +++ b/doc/api/config-test.json @@ -8,8 +8,6 @@ \"command\": \"config-test\", \"arguments\": { \"<server>\": { - }, - \"Logging\": { } } }", diff --git a/doc/examples/agent/comments.json b/doc/examples/agent/comments.json index d0d0c10798..b6a717740e 100644 --- a/doc/examples/agent/comments.json +++ b/doc/examples/agent/comments.json @@ -20,12 +20,8 @@ "socket-type": "unix", "socket-name": "/path/to/the/unix/socket-v4" } - } + }, - }, - - "Logging": - { // In loggers "loggers": [ { diff --git a/doc/examples/agent/simple.json b/doc/examples/agent/simple.json index b64a647a62..7a531c9317 100644 --- a/doc/examples/agent/simple.json +++ b/doc/examples/agent/simple.json @@ -66,13 +66,9 @@ "param1": "foo" } } - ] - - }, + ], - // Similar to other Kea components, CA also uses logging. - "Logging": - { + // Similar to other Kea components, CA also uses logging. "loggers": [ { "name": "kea-ctrl-agent", diff --git a/doc/examples/ddns/comments.json b/doc/examples/ddns/comments.json index f97005b098..0ee655cf2e 100644 --- a/doc/examples/ddns/comments.json +++ b/doc/examples/ddns/comments.json @@ -49,10 +49,8 @@ "algorithm": "HMAC-MD5", "secret": "LSWXnfkKZjdPJI5QxlpnfQ==" } - ] -}, + ], -"Logging": { // In loggers "loggers": [ { diff --git a/doc/examples/ddns/sample1.json b/doc/examples/ddns/sample1.json index 890fc08adf..2e1ed1378b 100644 --- a/doc/examples/ddns/sample1.json +++ b/doc/examples/ddns/sample1.json @@ -132,12 +132,10 @@ "digest-bits": 256, "secret": "/4wklkm04jeH4anx2MKGJLcya+ZLHldL5d6mK+4q6UXQP7KJ9mS2QG29hh0SJR4LA0ikxNJTUMvir42gLx6fGQ==" } - ] -}, + ], // The following configures logging. It assumes that messages with at least // informational level (info, warn, error and fatal) should be logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp-ddns", diff --git a/doc/examples/kea4/advanced.json b/doc/examples/kea4/advanced.json index 00380e59e7..38f71ed18a 100644 --- a/doc/examples/kea4/advanced.json +++ b/doc/examples/kea4/advanced.json @@ -172,14 +172,12 @@ "subnet": "192.0.5.0/24", "authoritative": true } - ] -}, - - // The following configures logging. It assumes that messages with - // at least informational level (info, warn, error and fatal) should - // be logged to stdout. - "Logging": { - "loggers": [ + ], + + // The following configures logging. It assumes that messages with + // at least informational level (info, warn, error and fatal) should + // be logged to stdout. + "loggers": [ { "name": "kea-dhcp4", "output_options": [ diff --git a/doc/examples/kea4/all-keys-current.json b/doc/examples/kea4/all-keys-current.json index 6a6457e95e..ff53006d04 100644 --- a/doc/examples/kea4/all-keys-current.json +++ b/doc/examples/kea4/all-keys-current.json @@ -790,12 +790,7 @@ "t1-percent": .5, // T2 = valid lifetime * .75. - "t2-percent": .75 - - }, - - // Logging configuration begins here. - "Logging": { + "t2-percent": .75, // List of loggers used by the servers using this configuration file. "loggers": [ diff --git a/doc/examples/kea4/all-keys-stable.json b/doc/examples/kea4/all-keys-stable.json index 4728a5fb09..babcd8587f 100644 --- a/doc/examples/kea4/all-keys-stable.json +++ b/doc/examples/kea4/all-keys-stable.json @@ -691,12 +691,8 @@ // Queue type was mandatory. "queue-type": "kea-ring4" - } + }, // Missing: calculate-tee-times, t1-percent, t2-percent - }, - - // Logging configuration begins here. - "Logging": { // List of loggers used by the servers using this configuration file. "loggers": [ diff --git a/doc/examples/kea4/backends.json b/doc/examples/kea4/backends.json index 47994bf25b..8238eaa71f 100644 --- a/doc/examples/kea4/backends.json +++ b/doc/examples/kea4/backends.json @@ -93,13 +93,11 @@ "subnet": "192.0.2.0/24", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/cassandra.json b/doc/examples/kea4/cassandra.json index d891225b3e..8d7d850417 100644 --- a/doc/examples/kea4/cassandra.json +++ b/doc/examples/kea4/cassandra.json @@ -100,13 +100,11 @@ "subnet": "192.0.2.0/24", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/classify.json b/doc/examples/kea4/classify.json index a44b030455..5a623b718f 100644 --- a/doc/examples/kea4/classify.json +++ b/doc/examples/kea4/classify.json @@ -121,13 +121,11 @@ "subnet": "192.0.4.0/23", "interface": "ethY" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/classify2.json b/doc/examples/kea4/classify2.json index f7cba5cc09..e9d82ac7bd 100644 --- a/doc/examples/kea4/classify2.json +++ b/doc/examples/kea4/classify2.json @@ -153,13 +153,11 @@ { "hw-address": "00:00:00:aa:bb:cc", "hostname": "ha" } ] } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/comments.json b/doc/examples/kea4/comments.json index 104e3479f8..13831113ae 100644 --- a/doc/examples/kea4/comments.json +++ b/doc/examples/kea4/comments.json @@ -101,10 +101,8 @@ "dhcp-ddns": { "comment": "No dynamic DNS", "enable-updates": false - } -}, + }, -"Logging": { // In loggers "loggers": [ { "comment": "A logger", diff --git a/doc/examples/kea4/dhcpv4-over-dhcpv6.json b/doc/examples/kea4/dhcpv4-over-dhcpv6.json index 1905cf8a36..779041b172 100644 --- a/doc/examples/kea4/dhcpv4-over-dhcpv6.json +++ b/doc/examples/kea4/dhcpv4-over-dhcpv6.json @@ -27,12 +27,8 @@ ], // This enables DHCPv4-over-DHCPv6 support - "dhcp4o6-port": 6767 + "dhcp4o6-port": 6767, -}, - -"Logging": -{ "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/global-reservations.json b/doc/examples/kea4/global-reservations.json index 0be0be490a..155b56aeea 100644 --- a/doc/examples/kea4/global-reservations.json +++ b/doc/examples/kea4/global-reservations.json @@ -142,13 +142,11 @@ "subnet": "192.0.2.0/24", "interface": "eth0" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/ha-load-balancing-primary.json b/doc/examples/kea4/ha-load-balancing-primary.json index 38500a90dd..6251f3cf47 100644 --- a/doc/examples/kea4/ha-load-balancing-primary.json +++ b/doc/examples/kea4/ha-load-balancing-primary.json @@ -192,13 +192,10 @@ // IP address. "relay": { "ip-address": "192.168.56.1" } } - ] -}, + ], -// Logging configuration starts here. -"Logging": -{ - "loggers": [ + // Logging configuration starts here. + "loggers": [ { // This section affects kea-dhcp4, which is the base logger for DHCPv4 // component. It tells DHCPv4 server to write all log messages (on diff --git a/doc/examples/kea4/leases-expiration.json b/doc/examples/kea4/leases-expiration.json index 4ce1a8cc23..cc499aaeb3 100644 --- a/doc/examples/kea4/leases-expiration.json +++ b/doc/examples/kea4/leases-expiration.json @@ -48,13 +48,11 @@ "subnet": "192.0.2.0/24", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/multiple-options.json b/doc/examples/kea4/multiple-options.json index 6a45c3ef3f..ee6fba7474 100644 --- a/doc/examples/kea4/multiple-options.json +++ b/doc/examples/kea4/multiple-options.json @@ -165,13 +165,11 @@ } ] } ] - } ] -}, + } ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/mysql-reservations.json b/doc/examples/kea4/mysql-reservations.json index 7e2c6d13df..01e1be67d4 100644 --- a/doc/examples/kea4/mysql-reservations.json +++ b/doc/examples/kea4/mysql-reservations.json @@ -76,13 +76,11 @@ "interface": "ethX", "id": 1 } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/pgsql-reservations.json b/doc/examples/kea4/pgsql-reservations.json index a7c3edb4a3..921d2dc114 100644 --- a/doc/examples/kea4/pgsql-reservations.json +++ b/doc/examples/kea4/pgsql-reservations.json @@ -78,13 +78,11 @@ "interface": "ethX", "id": 1 } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/reservations.json b/doc/examples/kea4/reservations.json index 0fcdb44b8f..61b18bd8b4 100644 --- a/doc/examples/kea4/reservations.json +++ b/doc/examples/kea4/reservations.json @@ -143,13 +143,11 @@ ] } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/several-subnets.json b/doc/examples/kea4/several-subnets.json index a7dfa62dae..b291c5975e 100644 --- a/doc/examples/kea4/several-subnets.json +++ b/doc/examples/kea4/several-subnets.json @@ -62,13 +62,11 @@ { "pools": [ { "pool": "192.0.4.1 - 192.0.4.254" } ], "subnet": "192.0.4.0/24" - } ] -}, + } ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/single-subnet.json b/doc/examples/kea4/single-subnet.json index 7d626b5eac..a71014b856 100644 --- a/doc/examples/kea4/single-subnet.json +++ b/doc/examples/kea4/single-subnet.json @@ -37,14 +37,12 @@ "subnet": "192.0.2.0/24", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. Alternatively, you can specify stderr here, a filename // or 'syslog', which will store output messages via syslog. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea4/with-ddns.json b/doc/examples/kea4/with-ddns.json index b019d3f527..a5bd324570 100644 --- a/doc/examples/kea4/with-ddns.json +++ b/doc/examples/kea4/with-ddns.json @@ -56,13 +56,11 @@ "qualifying-suffix" : "test.suffix.", "hostname-char-set": "[^A-Za-z0-9.-]", "hostname-char-replacement": "x" - } -}, + }, // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp4", diff --git a/doc/examples/kea6/advanced.json b/doc/examples/kea6/advanced.json index f64572a3f6..b1746bc195 100644 --- a/doc/examples/kea6/advanced.json +++ b/doc/examples/kea6/advanced.json @@ -155,13 +155,11 @@ "ip-address": "3000::1" } } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/all-keys-current.json b/doc/examples/kea6/all-keys-current.json index 8bf956df16..fb2cfe0b7a 100644 --- a/doc/examples/kea6/all-keys-current.json +++ b/doc/examples/kea6/all-keys-current.json @@ -749,11 +749,7 @@ "t1-percent": .5, // T2 = valid lifetime * .75. - "t2-percent": .75 - }, - - // Logging configuration begins here. - "Logging": { + "t2-percent": .75, // List of loggers used by the servers using this configuration file. "loggers": [ diff --git a/doc/examples/kea6/all-keys-stable.json b/doc/examples/kea6/all-keys-stable.json index 09737b5a89..a6a488d4d0 100644 --- a/doc/examples/kea6/all-keys-stable.json +++ b/doc/examples/kea6/all-keys-stable.json @@ -647,11 +647,7 @@ // Queue type was mandatory. "queue-type": "kea-ring6" - } - }, - - // Logging configuration begins here. - "Logging": { + }, // List of loggers used by the servers using this configuration file. "loggers": [ diff --git a/doc/examples/kea6/backends.json b/doc/examples/kea6/backends.json index 87009690d7..d03ba2f953 100644 --- a/doc/examples/kea6/backends.json +++ b/doc/examples/kea6/backends.json @@ -94,13 +94,11 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/cassandra.json b/doc/examples/kea6/cassandra.json index 6cf7ae03e1..f1bf18f9e1 100644 --- a/doc/examples/kea6/cassandra.json +++ b/doc/examples/kea6/cassandra.json @@ -100,13 +100,11 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/classify.json b/doc/examples/kea6/classify.json index 50c78e1a06..47e1e37ee8 100644 --- a/doc/examples/kea6/classify.json +++ b/doc/examples/kea6/classify.json @@ -88,13 +88,11 @@ "interface": "ethY" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/classify2.json b/doc/examples/kea6/classify2.json index 997dad3ad2..be3a071afd 100644 --- a/doc/examples/kea6/classify2.json +++ b/doc/examples/kea6/classify2.json @@ -124,13 +124,11 @@ ] } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/comments.json b/doc/examples/kea6/comments.json index 4bd6f767de..b00891f528 100644 --- a/doc/examples/kea6/comments.json +++ b/doc/examples/kea6/comments.json @@ -111,10 +111,8 @@ "dhcp-ddns": { "comment": "No dynamic DNS", "enable-updates": false - } -}, + }, -"Logging": { // In loggers "loggers": [ { "comment": "A logger", diff --git a/doc/examples/kea6/dhcpv4-over-dhcpv6.json b/doc/examples/kea6/dhcpv4-over-dhcpv6.json index 2acb41df8f..c2e6ad3dfb 100644 --- a/doc/examples/kea6/dhcpv4-over-dhcpv6.json +++ b/doc/examples/kea6/dhcpv4-over-dhcpv6.json @@ -38,12 +38,9 @@ "csv-format": true, // Put the server address here "data": "2001:db8:1:1::1" } - ] -}, + ], -"Logging": -{ - "loggers": [ + "loggers": [ { "name": "kea-dhcp6", "output_options": [ diff --git a/doc/examples/kea6/duid.json b/doc/examples/kea6/duid.json index 653ad9281e..a192507ddc 100644 --- a/doc/examples/kea6/duid.json +++ b/doc/examples/kea6/duid.json @@ -58,12 +58,10 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at least // informational level (info, warn, error) will will be logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/global-reservations.json b/doc/examples/kea6/global-reservations.json index 5f6118ea57..b5674178c1 100644 --- a/doc/examples/kea6/global-reservations.json +++ b/doc/examples/kea6/global-reservations.json @@ -136,13 +136,11 @@ ], "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/ha-hot-standby.json b/doc/examples/kea6/ha-hot-standby.json index 18ac41c957..5556aa903c 100644 --- a/doc/examples/kea6/ha-hot-standby.json +++ b/doc/examples/kea6/ha-hot-standby.json @@ -115,14 +115,12 @@ "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. Alternatively, you can specify stderr here, a filename // or 'syslog', which will store output messages via syslog. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/leases-expiration.json b/doc/examples/kea6/leases-expiration.json index ff2e5fa528..6a1ae5869b 100644 --- a/doc/examples/kea6/leases-expiration.json +++ b/doc/examples/kea6/leases-expiration.json @@ -56,13 +56,11 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/multiple-options.json b/doc/examples/kea6/multiple-options.json index 6fab01c443..ba20a63042 100644 --- a/doc/examples/kea6/multiple-options.json +++ b/doc/examples/kea6/multiple-options.json @@ -161,13 +161,11 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/mysql-reservations.json b/doc/examples/kea6/mysql-reservations.json index f400c43a69..0bd4968b58 100644 --- a/doc/examples/kea6/mysql-reservations.json +++ b/doc/examples/kea6/mysql-reservations.json @@ -73,13 +73,11 @@ "interface": "ethX", "id": 1 } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/pgsql-reservations.json b/doc/examples/kea6/pgsql-reservations.json index 6f930753df..eef6f70cbc 100644 --- a/doc/examples/kea6/pgsql-reservations.json +++ b/doc/examples/kea6/pgsql-reservations.json @@ -74,13 +74,11 @@ "interface": "ethX", "id": 1 } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/reservations.json b/doc/examples/kea6/reservations.json index 59e5e97eec..dad59d4f1e 100644 --- a/doc/examples/kea6/reservations.json +++ b/doc/examples/kea6/reservations.json @@ -132,13 +132,11 @@ ] } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/several-subnets.json b/doc/examples/kea6/several-subnets.json index 54acb74f10..bbebe365e4 100644 --- a/doc/examples/kea6/several-subnets.json +++ b/doc/examples/kea6/several-subnets.json @@ -39,14 +39,12 @@ { "pools": [ { "pool": "2001:db8:3::/80" } ], "subnet": "2001:db8:3::/64" }, { "pools": [ { "pool": "2001:db8:4::/80" } ], - "subnet": "2001:db8:4::/64" } ] -}, + "subnet": "2001:db8:4::/64" } ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { - "loggers": [ + "loggers": [ { "name": "kea-dhcp6", "output_options": [ diff --git a/doc/examples/kea6/simple.json b/doc/examples/kea6/simple.json index b47ca60f83..30903b52dc 100644 --- a/doc/examples/kea6/simple.json +++ b/doc/examples/kea6/simple.json @@ -39,14 +39,12 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] -}, + ], // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. Alternatively, you can specify stderr here, a filename // or 'syslog', which will store output messages via syslog. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/softwire46.json b/doc/examples/kea6/softwire46.json index 02e69455ce..a5750693d4 100644 --- a/doc/examples/kea6/softwire46.json +++ b/doc/examples/kea6/softwire46.json @@ -68,12 +68,10 @@ } ] } - ] -}, + ], // The following configures logging. Kea will log all debug messages // to /var/log/kea-debug.log file. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/kea6/with-ddns.json b/doc/examples/kea6/with-ddns.json index 04cde9edcc..dc52323816 100644 --- a/doc/examples/kea6/with-ddns.json +++ b/doc/examples/kea6/with-ddns.json @@ -58,14 +58,12 @@ "qualifying-suffix" : "test.suffix.", "hostname-char-set": "[^A-Za-z0-9.-]", "hostname-char-replacement": "x" - } + }, -}, // The following configures logging. It assumes that messages with at // least informational level (info, warn, error and fatal) should be // logged to stdout. -"Logging": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/examples/netconf/comments.json b/doc/examples/netconf/comments.json index 637996dd29..7f04e8d3ac 100644 --- a/doc/examples/netconf/comments.json +++ b/doc/examples/netconf/comments.json @@ -23,12 +23,8 @@ "socket-name": "/path/to/the/unix/socket-v4" } } - } + }, - }, - - "Logging": - { // In loggers "loggers": [ { diff --git a/doc/examples/netconf/kea-dhcp6-operations/netconf.json b/doc/examples/netconf/kea-dhcp6-operations/netconf.json index f5fdca8c2a..8c918065db 100644 --- a/doc/examples/netconf/kea-dhcp6-operations/netconf.json +++ b/doc/examples/netconf/kea-dhcp6-operations/netconf.json @@ -11,10 +11,8 @@ "socket-name": "/tmp/kea6-sock" } } - } - }, - "Logging": - { + }, + "loggers": [ { diff --git a/doc/examples/netconf/simple-dhcp4.json b/doc/examples/netconf/simple-dhcp4.json index 42f06214ce..b8f85e054f 100644 --- a/doc/examples/netconf/simple-dhcp4.json +++ b/doc/examples/netconf/simple-dhcp4.json @@ -64,7 +64,7 @@ "comment": "Kea DHCP4 server serving network on floor 13" } - } + }, // Netconf is able to load hook libraries that augment its operation. // The primary functionality is the ability to add new commands. @@ -86,11 +86,7 @@ // } //] - }, - - // Similar to other Kea components, Netconf also uses logging. - "Logging": - { + // Similar to other Kea components, Netconf also uses logging. "loggers": [ { "name": "kea-netconf", diff --git a/doc/examples/netconf/simple-dhcp6.json b/doc/examples/netconf/simple-dhcp6.json index 9ff8674412..5dbb22218e 100644 --- a/doc/examples/netconf/simple-dhcp6.json +++ b/doc/examples/netconf/simple-dhcp6.json @@ -65,7 +65,7 @@ "comment": "Kea DHCP6 server serving network on floor 13" } - } + }, // Netconf is able to load hook libraries that augment its operation. // The primary functionality is the ability to add new commands. @@ -87,11 +87,7 @@ // } //] - }, - - // Similar to other Kea components, Netconf also uses logging. - "Logging": - { + // Similar to other Kea components, Netconf also uses logging. "loggers": [ { "name": "kea-netconf", diff --git a/doc/guide/agent.xml b/doc/guide/agent.xml index 63da66af44..347f0b440b 100644 --- a/doc/guide/agent.xml +++ b/doc/guide/agent.xml @@ -1,5 +1,5 @@ <!-- - - Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") + - Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this @@ -91,10 +91,8 @@ "parameters": { "param1": "foo" } - } ] - }, + } ], - "Logging": { "loggers": [ { "name": "kea-ctrl-agent", "severity": "INFO" diff --git a/doc/guide/api.xml b/doc/guide/api.xml index f030825b6b..b251296574 100644 --- a/doc/guide/api.xml +++ b/doc/guide/api.xml @@ -959,8 +959,6 @@ Result is an integer representation of the status. Currently supported statuses "command": "config-set", "arguments": { "<server>": { - }, - "Logging": { } } }</screen> @@ -1000,8 +998,6 @@ Result is an integer representation of the status. Currently supported statuses "command": "config-test", "arguments": { "<server>": { - }, - "Logging": { } } }</screen> diff --git a/doc/guide/config.xml b/doc/guide/config.xml index 2c7f2d2e0a..f391154c6d 100644 --- a/doc/guide/config.xml +++ b/doc/guide/config.xml @@ -1,5 +1,5 @@ <!-- - - Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") + - Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this @@ -65,8 +65,8 @@ <para>The configuration file consists of a single object (often colloquially called a map) started with a curly bracket. It - comprises one or more of the "Dhcp4", "Dhcp6", "DhcpDdns", "Control-agent", - "Netconf", and "Logging" objects. It is possible to define + comprises one or more of the "Dhcp4", "Dhcp6", "DhcpDdns", + "Control-agent" and "Netconf" objects. It is possible to define additional elements but they will be ignored.</para> <para>A very simple configuration for DHCPv4 could look like this: @@ -85,11 +85,9 @@ "subnet4": [{ "pools": [ { "pool": "192.0.2.1-192.0.2.200" } ], "subnet": "192.0.2.0/24" - }] - }, + }], - # Logger configuration starts here. - "Logging": { + # Now loggers are inside the DHCPv4 object. "loggers": [{ "name": "*", "severity": "DEBUG" @@ -106,12 +104,12 @@ <note> <para> - The "Logging" element will be removed in Kea 1.6.0 and its contents + The "Logging" element is removed in Kea 1.6.0 and its contents (the "loggers" object) moved inside the configuration objects (maps) for - the respective Kea modules. For example, the "Dhcp4" map will contain the + respective Kea modules. For example: the "Dhcp4" map contains the "loggers" object specifying logging configuration for the DHCPv4 - server. Backward compatibility will be maintained until at least Kea - 1.7.0; it will be possible to specify the "Logging" object + server. Backward compatibility is maintained until at least Kea + 1.7.0 release: it will be possible to specify "Logging" object at the top configuration level and "loggers" objects at the module configuration level. Ultimately, support for the top-level "Logging" object will be removed. diff --git a/doc/guide/ctrl-channel.xml b/doc/guide/ctrl-channel.xml index 9a408a3c51..9526c1be55 100644 --- a/doc/guide/ctrl-channel.xml +++ b/doc/guide/ctrl-channel.xml @@ -340,8 +340,6 @@ $ curl -X POST -H "Content-Type: application/json" -d '{ "command": "config-get" "command": "config-test", "arguments": { "<server>": { - }, - "Logging": { } } } @@ -356,9 +354,6 @@ $ curl -X POST -H "Content-Type: application/json" -d '{ "command": "config-get" "arguments": { "Dhcp6": { : - }, - "Logging": { - : } } } @@ -487,8 +482,6 @@ $ curl -X POST -H "Content-Type: application/json" -d '{ "command": "config-get" "command": "config-set", "arguments": { "<server>": { - }, - "Logging": { } } } @@ -503,9 +496,6 @@ $ curl -X POST -H "Content-Type: application/json" -d '{ "command": "config-get" "arguments": { "Dhcp6": { : - }, - "Logging": { - : } } } diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 5b6b2b0e9d..e52fe9a6c1 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -193,10 +193,12 @@ In the example above this object is called <command>Dhcp4</command>. <note> <para>In the current Kea release it is possible to specify configurations of multiple modules within a single configuration file, but this is not - recommended. The - only object, besides the one specifying module configuration, which can be - (and usually is) included in the same file, is the <command>Logging</command> object. - However, we don't include this one in the example above for clarity. + recommended and support for it will be removed in the future releases. The + only object, besides the one specifying module configuration, which can + (and usually was) included in the same file is <command>Logging</command>. + However, we don't include this object in the example above for clarity + and its content, the list of loggers, should now be inside the + <command>Dhcp4</command> object instead of the deprecated object. </para> </note> @@ -303,10 +305,8 @@ In some cases it may be preferable to use more compact notation. </para> <para>After all the parameters have been specified, we have two contexts open: -global and Dhcp4, so we need two closing curly brackets to close them. -In a real-life configuration file there most likely would be an additional -component defined such as Logging, so the first closing brace would be followed -by a comma and another object definition.</para> +global and Dhcp4, hence we need two closing curly brackets to close them. +</para> </section> <section> @@ -3559,11 +3559,8 @@ It is merely echoed by the server. "pools": [ { "pool": "10.10.10.100 - 10.10.10.199" } ] } ], - <userinput>"dhcp4o6-port": 6767</userinput> - -}, + <userinput>"dhcp4o6-port": 6767,</userinput> -"Logging": { "loggers": [ { "name": "kea-dhcp4", "output_options": [ { diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index 95ecbfcb29..ec0610dabf 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -194,10 +194,12 @@ In the example above this object is called <command>Dhcp6</command>. <note> <para>In the current Kea release it is possible to specify configurations of multiple modules within a single configuration file, but this is not - recommended. The - only object, besides the one specifying module configuration, which can be - (and usually is) included in the same file, is the <command>Logging</command> object. - However, we don't include this object in the example above for clarity. + recommended and support for it will be removed in the future releases. The + only object, besides the one specifying module configuration, which can + (and usually was) included in the same file is <command>Logging</command>. + However, we don't include this object in the example above for clarity + and its content, the list of loggers, should now be inside the + <command>Dhcp4</command> object instead of this deprecated object. </para> </note> @@ -292,10 +294,8 @@ In some cases in may be preferable to use more compact notation. </para> <para>After all parameters are specified, we have two contexts open: -global and Dhcp6, so we need two closing curly brackets to close them. -In a real-life configuration file there most likely would be additional -components defined such as Logging, so the first closing brace would be followed -by a comma and another object definition.</para> +global and Dhcp6, hence we need two closing curly brackets to close them. +</para> </section> <section> @@ -3107,11 +3107,9 @@ should include options from the new option space: "space": "dhcp6", "csv-format": true, "data": "2001:db8:1:1::1" - } ] + } ], </userinput> -}, -"Logging": { "loggers": [ { "name": "kea-dhcp6", "output_options": [ { diff --git a/doc/guide/logging.xml b/doc/guide/logging.xml index d5edef2116..f6e2f92d7f 100644 --- a/doc/guide/logging.xml +++ b/doc/guide/logging.xml @@ -1,5 +1,5 @@ <!-- - - Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") + - Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this @@ -23,12 +23,10 @@ </para> <para> - The logging system in Kea is configured through the - Logging section in your configuration - file. All daemons (e.g. DHCPv4 and DHCPv6 servers) will use the - configuration in the Logging section to see - what should be logged and to where. This allows for sharing identical - logging configuration between daemons. + The logging system in Kea is configured through the loggers entry + in the server section of your configuration file. In previous + Kea releases this entry was in an independent Logging section, + this is still supported for backward compatibility. </para> <section> @@ -61,7 +59,7 @@ </para> <para> - In the Logging section of a configuration file you can specify the + In the server section of a configuration file you can specify the configuration for zero or more loggers (including loggers used by the proprietary hooks libraries). If there are no loggers specified, the code will use default values; these cause Kea to log messages of INFO @@ -146,17 +144,6 @@ configuration. </para> - <!-- we don't support asterisk anymore. - <para> - One special case is that of a component name of <quote>*</quote> - (asterisks), which is interpreted as <emphasis>any</emphasis> - component. You can set global logging options by using this, - including setting the logging configuration for a library - that is used by multiple daemons (e.g. <quote>*.config</quote> - specifies the configuration library code in whatever - daemon is using it). - </para> --> - <para> If there are multiple logger specifications in the configuration that might match a particular logger, the specification with the @@ -225,6 +212,7 @@ <row><entry><command>kea-dhcp-ddns.dhcpddns</command></entry><entry>core</entry><entry>The logger used by the kea-dhcp-ddns daemon for logging events related to DDNS operations.</entry></row> <row><entry><command>kea-dhcp-ddns.dhcp-to-d2</command></entry><entry>core</entry><entry>Used by the kea-dhcp-ddns daemon for logging information about events dealing with receiving messages from the DHCP servers and adding them to the queue for processing.</entry></row> <row><entry><command>kea-dhcp-ddns.d2-to-dns</command></entry><entry>core</entry><entry>Used by the kea-dhcp-ddns daemon for logging information about events dealing with sending and receiving messages with the DNS servers.</entry></row> + <row><entry><command>kea-netconf</command></entry><entry>core</entry><entry>The root logger for the Netconf agent. All components used by Netconf inherit the settings from this logger if there is no specialized logger provided.</entry></row> </tbody> </tgroup> </table> @@ -406,11 +394,11 @@ <section> <title>Example Logger Configurations</title> <para> - In this example we want to set the global logging to write to the + In this example we want to set the Server logging to write to the console using standard output. </para> -<screen><userinput>"Logging": { +<screen><userinput>"Server": { "loggers": [ { "name": "kea-dhcp4", @@ -431,7 +419,7 @@ created. </para> -<screen><userinput>"Logging": { +<screen><userinput>"Server": { "loggers": [ { "name": "kea-dhcp6", diff --git a/doc/guide/netconf.xml b/doc/guide/netconf.xml index 85f4a6a11f..0bd63a599c 100644 --- a/doc/guide/netconf.xml +++ b/doc/guide/netconf.xml @@ -1,5 +1,5 @@ <!-- - - Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") + - Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this @@ -619,13 +619,9 @@ done in dependency order and reverse dependency order accordingly. "param1": "foo" } } - ] - - }, + ], - // Similar to other Kea components, kea-netconf also uses logging. - "Logging": - { + // Similar to other Kea components, Netconf also uses logging. "loggers": [ { "name": "kea-netconf", @@ -794,10 +790,8 @@ done in dependency order and reverse dependency order accordingly. "socket-name": "/tmp/kea6-sock" } } - } - }, - "Logging": - { + }, + "loggers": [ { @@ -1077,7 +1071,7 @@ done in dependency order and reverse dependency order accordingly. <section xml:id="operation-example-logging"> <title>NETCONF Operation Example with Logging</title> <para> - This example adds a Logging section to the initial (i.e. startup) + This example adds a logger entry to the initial (i.e. startup) configuration in the <filename>logging.xml</filename> file: <screen> <config xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp6-server"> @@ -1131,9 +1125,7 @@ done in dependency order and reverse dependency order accordingly. ], "subnet": "2001:db8::/64" } - ] - }, - "Logging": { + ], "loggers": [ { "name": "kea-dhcp6", diff --git a/src/bin/agent/ca_cfg_mgr.cc b/src/bin/agent/ca_cfg_mgr.cc index 20c193bd10..5bf87e5e94 100644 --- a/src/bin/agent/ca_cfg_mgr.cc +++ b/src/bin/agent/ca_cfg_mgr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -145,7 +145,7 @@ CtrlAgentCfgContext::getControlSocketInfoSummary() const { ElementPtr CtrlAgentCfgContext::toElement() const { - ElementPtr ca = Element::createMap(); + ElementPtr ca = ConfigBase::toElement(); // Set user-context contextToElement(ca); // Set http-host @@ -165,8 +165,6 @@ CtrlAgentCfgContext::toElement() const { ElementPtr result = Element::createMap(); result->set("Control-agent", ca); - // Set Logging (not yet) - return (result); } diff --git a/src/bin/agent/parser_context.h b/src/bin/agent/parser_context.h index 2fbc0d272b..c7271a89ea 100644 --- a/src/bin/agent/parser_context.h +++ b/src/bin/agent/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -173,10 +173,10 @@ public: ///< Used while parsing Control-agent/hooks-libraries. HOOKS_LIBRARIES, - ///< Used while parsing Logging/loggers structures. + ///< Used while parsing Control-agent/loggers structures. LOGGERS, - ///< Used while parsing Logging/loggers/output_options structures. + ///< Used while parsing Control-agent/loggers/output_options structures. OUTPUT_OPTIONS } LexerContext; diff --git a/src/bin/d2/d2_cfg_mgr.cc b/src/bin/d2/d2_cfg_mgr.cc index a79a839d08..2f248004d3 100644 --- a/src/bin/d2/d2_cfg_mgr.cc +++ b/src/bin/d2/d2_cfg_mgr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -60,7 +60,7 @@ D2CfgContext::~D2CfgContext() { ElementPtr D2CfgContext::toElement() const { - ElementPtr d2 = Element::createMap(); + ElementPtr d2 = ConfigBase::toElement(); // Set user-context contextToElement(d2); // Set ip-address diff --git a/src/bin/d2/parser_context.h b/src/bin/d2/parser_context.h index 682043ba4f..179862ea84 100644 --- a/src/bin/d2/parser_context.h +++ b/src/bin/d2/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -210,10 +210,10 @@ public: ///< Used while parsing content of Logging LOGGING, - /// Used while parsing Logging/loggers structures. + /// Used while parsing DhcpDdns/loggers structures. LOGGERS, - /// Used while parsing Logging/loggers/output_options structures. + /// Used while parsing DhcpDdns/loggers/output_options structures. OUTPUT_OPTIONS, /// Used while parsing DhcpDdns/ncr-protocol diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 0595c1ad01..8fa7b20db4 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -304,9 +304,8 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, string message; // Command arguments are expected to be: - // { "Dhcp4": { ... }, "Logging": { ... } } - // The Logging component is technically optional. If it's not supplied - // logging will revert to default logging. + // { "Dhcp4": { ... } } + // The Logging component is supported by backward compatiblity. if (!args) { message = "Missing mandatory 'arguments' parameter."; } else { @@ -330,19 +329,27 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, // configuration attempts. CfgMgr::instance().rollback(); - // Logging is a sibling element and must be parsed explicitly. - // The call to configureLogger parses the given Logging element if - // not null, into the staging config. Note this does not alter the - // current loggers, they remain in effect until we apply the - // logging config below. If no logging is supplied logging will - // revert to default logging. - Daemon::configureLogger(args->get("Logging"), - CfgMgr::instance().getStagingCfg()); + // Check obsolete objects. + + // Check deprecated objects. + + // Relocate Logging. + Daemon::relocateLogging(args, "Dhcp4"); + + // Parse the logger configuration explicitly into the staging config. + // Note this does not alter the current loggers, they remain in + // effect until we apply the logging config below. If no logging + // is supplied logging will revert to default logging. + Daemon::configureLogger(dhcp4, CfgMgr::instance().getStagingCfg()); // Let's apply the new logging. We do it early, so we'll be able to print // out what exactly is wrong with the new socnfig in case of problems. CfgMgr::instance().getStagingCfg()->applyLoggingCfg(); + // Log deprecated objects. + + // Log obsolete objects and return an error. + // Now we configure the server proper. ConstElementPtr result = processConfig(dhcp4); @@ -374,9 +381,8 @@ ControlledDhcpv4Srv::commandConfigTestHandler(const string&, string message; // Command arguments are expected to be: - // { "Dhcp4": { ... }, "Logging": { ... } } - // The Logging component is technically optional. If it's not supplied - // logging will revert to default logging. + // { "Dhcp4": { ... } } + // The Logging component is supported by backward compatiblity. if (!args) { message = "Missing mandatory 'arguments' parameter."; } else { @@ -400,6 +406,13 @@ ControlledDhcpv4Srv::commandConfigTestHandler(const string&, // configuration attempts. CfgMgr::instance().rollback(); + // Check obsolete objects. + + // Relocate Logging. Note this allows to check the loggers configuration. + Daemon::relocateLogging(args, "Dhcp4"); + + // Log obsolete objects and return an error. + // Now we check the server proper. return (checkConfig(dhcp4)); } diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.h b/src/bin/dhcp4/ctrl_dhcp4_srv.h index c3120af240..0b2a471fac 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.h +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.h @@ -205,7 +205,8 @@ private: /// @param command (parameter ignored) /// @param args configuration to be processed. Expected format: /// map containing Dhcp4 map that contains DHCPv4 server configuration. - /// May also contain Logging map that specifies logging configuration. + /// May also contain Logging map that specifies logging configuration + /// for backward compatibility. /// /// @return status of the command isc::data::ConstElementPtr @@ -219,7 +220,8 @@ private: /// @param command (parameter ignored) /// @param args configuration to be checked. Expected format: /// map containing Dhcp4 map that contains DHCPv4 server configuration. - /// May also contain Logging map that specifies logging configuration. + /// May also contain Logging map that specifies logging configuration + /// for backward compatibility. /// /// @return status of the command isc::data::ConstElementPtr diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 4d0bd3a0a8..b3f58c2b2f 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC") # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -134,6 +134,14 @@ new configuration. It is output during server startup, and when an updated configuration is committed by the administrator. Additional information may be provided. +% DHCP4_CONFIG_DEPRECATED DHCPv4 server configuration includes a deprecated object: %1 +This warning message is issued when the configuration includes a deprecated +object (i.e. a top level element) which will be ignored. + +% DHCP4_CONFIG_FETCH Fetching configuration data from config backends. +This is an informational message emitted when the DHCPv4 server about to begin +retrieving configuration data from one or more configuration backends. + % DHCP4_CONFIG_LOAD_FAIL configuration error using file: %1, reason: %2 This error message indicates that the DHCPv4 configuration has failed. If this is an initial configuration (during server's startup) the server @@ -144,6 +152,10 @@ server will continue to use an old configuration. This is an informational message reporting that the configuration has been extended to include the specified IPv4 subnet. +% DHCP4_CONFIG_OBSOLETE DHCPv4 server configuration includes an obsolete object: %1 +This error message is issued when the configuration includes an obsolete +object (i.e. a top level element). + % DHCP4_CONFIG_OPTION_DUPLICATE multiple options with the code %1 added to the subnet %2 This warning message is issued on an attempt to configure multiple options with the same option code for a particular subnet. Adding multiple options diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 51b08d7272..227e2a2274 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -556,7 +556,8 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, (config_pair.first == "reservation-mode") || (config_pair.first == "calculate-tee-times") || (config_pair.first == "t1-percent") || - (config_pair.first == "t2-percent")) { + (config_pair.first == "t2-percent") || + (config_pair.first == "loggers")) { CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first, config_pair.second); diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index ae95f02c07..a36b311d1e 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -282,10 +282,10 @@ public: /// Used while parsing Dhcp4/subnet4relay structures. RELAY, - /// Used while parsing Logging/loggers structures. + /// Used while parsing Dhcp4/loggers structures. LOGGERS, - /// Used while parsing Logging/loggers/output_options structures. + /// Used while parsing Dhcp4/loggers/output_options structures. OUTPUT_OPTIONS, /// Used while parsing Dhcp4/dhcp-ddns. diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index c76c82af98..7fd7de4cdd 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -306,9 +306,8 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, string message; // Command arguments are expected to be: - // { "Dhcp6": { ... }, "Logging": { ... } } - // The Logging component is technically optional. If it's not supplied - // logging will revert to default logging. + // { "Dhcp6": { ... } } + // The Logging component is supported by backward compatiblity. if (!args) { message = "Missing mandatory 'arguments' parameter."; } else { @@ -332,19 +331,27 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, // configuration attempts. CfgMgr::instance().rollback(); - // Logging is a sibling element and must be parsed explicitly. - // The call to configureLogger parses the given Logging element if - // not null, into the staging config. Note this does not alter the - // current loggers, they remain in effect until we apply the - // logging config below. If no logging is supplied logging will - // revert to default logging. - Daemon::configureLogger(args->get("Logging"), - CfgMgr::instance().getStagingCfg()); + // Check obsolete objects. + + // Check deprecated objects. + + // Relocate Logging. + Daemon::relocateLogging(args, "Dhcp6"); + + // Parse the logger configuration explicitly into the staging config. + // Note this does not alter the current loggers, they remain in + // effect until we apply the logging config below. If no logging + // is supplied logging will revert to default logging. + Daemon::configureLogger(dhcp6, CfgMgr::instance().getStagingCfg()); // Let's apply the new logging. We do it early, so we'll be able to print // out what exactly is wrong with the new socnfig in case of problems. CfgMgr::instance().getStagingCfg()->applyLoggingCfg(); + // Log deprecated objects. + + // Log obsolete objects and return an error. + // Now we configure the server proper. ConstElementPtr result = processConfig(dhcp6); @@ -376,9 +383,8 @@ ControlledDhcpv6Srv::commandConfigTestHandler(const string&, string message; // Command arguments are expected to be: - // { "Dhcp6": { ... }, "Logging": { ... } } - // The Logging component is technically optional. If it's not supplied - // logging will revert to default logging. + // { "Dhcp6": { ... } } + // The Logging component is supported by backward compatiblity. if (!args) { message = "Missing mandatory 'arguments' parameter."; } else { @@ -402,6 +408,13 @@ ControlledDhcpv6Srv::commandConfigTestHandler(const string&, // configuration attempts. CfgMgr::instance().rollback(); + // Check obsolete objects. + + // Relocate Logging. Note this allows to check the loggers configuration. + Daemon::relocateLogging(args, "Dhcp4"); + + // Log obsolete objects and return an error. + // Now we check the server proper. return (checkConfig(dhcp6)); } diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.h b/src/bin/dhcp6/ctrl_dhcp6_srv.h index ef776c83a8..c859115aa6 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.h +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.h @@ -205,7 +205,8 @@ private: /// @param command (parameter ignored) /// @param args configuration to be processed. Expected format: /// map containing Dhcp6 map that contains DHCPv6 server configuration. - /// May also contain Logging map that specifies logging configuration. + /// May also contain Logging map that specifies logging configuration + /// for backward compatibility. /// /// @return status of the command isc::data::ConstElementPtr @@ -219,7 +220,8 @@ private: /// @param command (parameter ignored) /// @param args configuration to be checked. Expected format: /// map containing Dhcp6 map that contains DHCPv6 server configuration. - /// May also contain Logging map that specifies logging configuration. + /// May also contain Logging map that specifies logging configuration + /// for backward compatibility. /// /// @return status of the command isc::data::ConstElementPtr diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 53bb696a77..7328687f96 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -98,12 +98,20 @@ new configuration. it is output during server startup, and when an updated configuration is committed by the administrator. Additional information may be provided. +% DHCP6_CONFIG_DEPRECATED DHCPv6 server configuration includes a deprecated object: %1 +This warning message is issued when the configuration includes a deprecated +object (i.e. a top level element) which will be ignored. + % DHCP6_CONFIG_LOAD_FAIL configuration error using file: %1, reason: %2 This error message indicates that the DHCPv6 configuration has failed. If this is an initial configuration (during server's startup) the server will fail to start. If this is a dynamic reconfiguration attempt the server will continue to use an old configuration. +% DHCP6_CONFIG_OBSOLETE DHCPv6 server configuration includes an obsolete object: %1 +This error message is issued when the configuration includes an obsolete +object (i.e. a top level element). + % DHCP6_CONFIG_PACKET_QUEUE DHCPv6 packet queue info after configuration: %1 This informational message is emitted during DHCPv6 server configuration, immediately after configuring the DHCPv6 packet queue. The information diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index b495e41ed7..a0068ecf8f 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -673,7 +673,8 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set, (config_pair.first == "reservation-mode") || (config_pair.first == "calculate-tee-times") || (config_pair.first == "t1-percent") || - (config_pair.first == "t2-percent")) { + (config_pair.first == "t2-percent") || + (config_pair.first == "loggers")) { CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first, config_pair.second); diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index aea40cc28b..513aa02daa 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -289,10 +289,10 @@ public: /// Used while parsing Dhcp6/subnet6/relay structures. RELAY, - /// Used while parsing Logging/loggers structures. + /// Used while parsing Dhcp6/loggers structures. LOGGERS, - /// Used while parsing Logging/loggers/output_options structures. + /// Used while parsing Dhcp6/loggers/output_options structures. OUTPUT_OPTIONS, /// Used while parsing Dhcp6/dhcp-ddns. diff --git a/src/bin/keactrl/kea-ctrl-agent.conf.pre b/src/bin/keactrl/kea-ctrl-agent.conf.pre index 94177a7068..b887a90b8b 100644 --- a/src/bin/keactrl/kea-ctrl-agent.conf.pre +++ b/src/bin/keactrl/kea-ctrl-agent.conf.pre @@ -50,14 +50,11 @@ // "param1": "foo" // } // } - ] -}, + ], // Logging configuration starts here. Kea uses different loggers to log various // activities. For details (e.g. names of loggers), see Chapter 18. -"Logging": -{ - "loggers": [ + "loggers": [ { // This specifies the logging for Control Agent daemon. "name": "kea-ctrl-agent", diff --git a/src/bin/keactrl/kea-dhcp-ddns.conf.pre b/src/bin/keactrl/kea-dhcp-ddns.conf.pre index d56119f74c..cc75cf1eb1 100644 --- a/src/bin/keactrl/kea-dhcp-ddns.conf.pre +++ b/src/bin/keactrl/kea-dhcp-ddns.conf.pre @@ -27,13 +27,10 @@ }, "tsig-keys": [], "forward-ddns" : {}, - "reverse-ddns" : {} -}, + "reverse-ddns" : {}, // Logging configuration starts here. Kea uses different loggers to log various // activities. For details (e.g. names of loggers), see Chapter 18. -"Logging": -{ "loggers": [ { // This specifies the logging for D2 (DHCP-DDNS) daemon. diff --git a/src/bin/keactrl/kea-dhcp4.conf.pre b/src/bin/keactrl/kea-dhcp4.conf.pre index 126b9b4081..a2d7876962 100644 --- a/src/bin/keactrl/kea-dhcp4.conf.pre +++ b/src/bin/keactrl/kea-dhcp4.conf.pre @@ -410,13 +410,10 @@ // There are many, many more parameters that DHCPv4 server is able to use. // They were not added here to not overwhelm people with too much // information at once. -}, // Logging configuration starts here. Kea uses different loggers to log various // activities. For details (e.g. names of loggers), see Chapter 18. -"Logging": -{ - "loggers": [ + "loggers": [ { // This section affects kea-dhcp4, which is the base logger for DHCPv4 // component. It tells DHCPv4 server to write all log messages (on diff --git a/src/bin/keactrl/kea-dhcp6.conf.pre b/src/bin/keactrl/kea-dhcp6.conf.pre index 5b44143380..d3e5083378 100644 --- a/src/bin/keactrl/kea-dhcp6.conf.pre +++ b/src/bin/keactrl/kea-dhcp6.conf.pre @@ -337,13 +337,9 @@ // DDNS information (how the DHCPv6 component can reach a DDNS daemon) -}, - // Logging configuration starts here. Kea uses different loggers to log various // activities. For details (e.g. names of loggers), see Chapter 18. -"Logging": -{ - "loggers": [ + "loggers": [ { // This specifies the logging for kea-dhcp6 logger, i.e. all logs // generated by Kea DHCPv6 server. diff --git a/src/bin/keactrl/kea-netconf.conf.pre b/src/bin/keactrl/kea-netconf.conf.pre index d445e8b155..f68e24fddd 100644 --- a/src/bin/keactrl/kea-netconf.conf.pre +++ b/src/bin/keactrl/kea-netconf.conf.pre @@ -53,13 +53,10 @@ // } // } // ] -}, // Logging configuration starts here. Kea uses different loggers to log various // activities. For details (e.g. names of loggers), see Chapter 18. -"Logging": -{ - "loggers": [ + "loggers": [ { // This specifies the logging for Netconf daemon. "name": "kea-netconf", diff --git a/src/bin/netconf/netconf_cfg_mgr.cc b/src/bin/netconf/netconf_cfg_mgr.cc index 5cddc3a5c2..7208280723 100644 --- a/src/bin/netconf/netconf_cfg_mgr.cc +++ b/src/bin/netconf/netconf_cfg_mgr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -144,7 +144,7 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set, ElementPtr NetconfConfig::toElement() const { - ElementPtr netconf = Element::createMap(); + ElementPtr netconf = ConfigBase::toElement(); // Set user-context contextToElement(netconf); // Add in explicitly configured globals. @@ -161,9 +161,6 @@ NetconfConfig::toElement() const { // Set Netconf ElementPtr result = Element::createMap(); result->set("Netconf", netconf); - - // Set Logging (not yet) - return (result); } diff --git a/src/bin/netconf/parser_context.h b/src/bin/netconf/parser_context.h index a75a89c477..b83fc09ecb 100644 --- a/src/bin/netconf/parser_context.h +++ b/src/bin/netconf/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -190,10 +190,10 @@ public: ///< Used while parsing Netconf/hooks-libraries. HOOKS_LIBRARIES, - ///< Used while parsing Logging/loggers structures. + ///< Used while parsing Netconf/loggers structures. LOGGERS, - ///< Used while parsing Logging/loggers/output_options structures. + ///< Used while parsing Netconf/loggers/output_options structures. OUTPUT_OPTIONS } LexerContext; diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc index a4d3b59a61..3c2da71e92 100644 --- a/src/lib/dhcpsrv/srv_config.cc +++ b/src/lib/dhcpsrv/srv_config.cc @@ -295,12 +295,12 @@ SrvConfig::extractConfiguredGlobals(isc::data::ConstElementPtr config) { ElementPtr SrvConfig::toElement() const { // Toplevel map - ElementPtr result = ConfigBase::toElement(); + ElementPtr result = Element::createMap(); // Get family for the configuration manager uint16_t family = CfgMgr::instance().getFamily(); // DhcpX global map - ElementPtr dhcp = Element::createMap(); + ElementPtr dhcp = ConfigBase::toElement(); // Add in explicitly configured globals. dhcp->setValue(configured_globals_->mapValue()); diff --git a/src/lib/process/config_base.cc b/src/lib/process/config_base.cc index 6e9ffd6e82..378acd19c1 100644 --- a/src/lib/process/config_base.cc +++ b/src/lib/process/config_base.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -111,9 +111,8 @@ ElementPtr ConfigBase::toElement() const { ElementPtr result = Element::createMap(); - // Logging global map (skip if empty) + // Was in the Logging global map. if (!logging_info_.empty()) { - ElementPtr logging = Element::createMap(); // Set loggers list ElementPtr loggers = Element::createList(); for (LoggingInfoStorage::const_iterator logger = @@ -121,8 +120,7 @@ ConfigBase::toElement() const { logger != logging_info_.cend(); ++logger) { loggers->add(logger->toElement()); } - logging->set("loggers", loggers); - result->set("Logging", logging); + result->set("loggers", loggers); } // server-tag @@ -130,6 +128,7 @@ ConfigBase::toElement() const { result->set("server-tag", Element::create(server_tag_.get())); } + // Note this comment below is obsolete... // We do NOT output ConfigControlInfo here, as it is not a // top level element, but rather belongs within the process // element. diff --git a/src/lib/process/config_base.h b/src/lib/process/config_base.h index e1965b317c..32de6b3f4c 100644 --- a/src/lib/process/config_base.h +++ b/src/lib/process/config_base.h @@ -86,7 +86,7 @@ public: /// as JSON): /// {{{ /// { - /// "Logging": { + /// "Server": { /// : /// } /// } diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index a1c3597a98..234214cf58 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -186,6 +186,17 @@ DControllerBase::checkConfigOnly() { isc_throw(InvalidUsage, "Config file " << config_file << " does not include '" << getAppName() << "' entry"); } + if (module_config->getType() != Element::map) { + isc_throw(InvalidUsage, "Config file " << config_file << + " include not map '" << getAppName() << "' entry"); + } + + // Check obsolete objects. + + // Relocate Logging. + Daemon::relocateLogging(whole_config, getAppName()); + + // Log obsolete objects and return an error. // Get an application process object. initProcess(); @@ -345,6 +356,25 @@ DControllerBase::configFromFile() { whole_config = Element::fromJSONFile(config_file, true); } + // Extract derivation-specific portion of the configuration. + module_config = whole_config->get(getAppName()); + if (!module_config) { + isc_throw(BadValue, "Config file " << config_file << + " does not include '" << + getAppName() << "' entry."); + } + if (module_config->getType() != Element::map) { + isc_throw(InvalidUsage, "Config file " << config_file << + " include not map '" << getAppName() << "' entry"); + } + + // Check obsolete objects. + + // Check deprecated objects. + + // Relocate Logging. + Daemon::relocateLogging(whole_config, getAppName()); + // Let's configure logging before applying the configuration, // so we can log things during configuration process. @@ -353,15 +383,11 @@ DControllerBase::configFromFile() { // Get 'Logging' element from the config and use it to set up // logging. If there's no such element, we'll just pass NULL. - Daemon::configureLogger(whole_config->get("Logging"), storage); + Daemon::configureLogger(module_config, storage); - // Extract derivation-specific portion of the configuration. - module_config = whole_config->get(getAppName()); - if (!module_config) { - isc_throw(BadValue, "Config file " << config_file << - " does not include '" << - getAppName() << "' entry."); - } + // Log deprecated objects. + + // Log obsolete objects and return an error. answer = updateConfig(module_config); int rcode = 0; diff --git a/src/lib/process/d_controller.h b/src/lib/process/d_controller.h index 79cf4f1dde..8f971a0451 100644 --- a/src/lib/process/d_controller.h +++ b/src/lib/process/d_controller.h @@ -186,9 +186,6 @@ public: /// /// @code /// { "<module-name>": {<module-config>} - /// - /// # Logging element is optional - /// ,"Logging": {<logger config} /// } /// /// where: @@ -204,12 +201,11 @@ public: /// file content using an alternate parser. If it returns an empty pointer /// than the JSON parsing providing by Element::fromJSONFile() is called. /// - /// Once parsed, the method looks for the Element "Logging" and, if present - /// uses it to configure logging. - /// - /// It then extracts the set of configuration elements for the - /// module-name that matches the controller's app_name_ and passes that - /// set into @c updateConfig() (or @c checkConfig()). + /// Once parsed, the method extracts the set of configuration + /// elements for the module-name that matches the controller's app_name_, + /// looks for the loggers entry and, if present uses it to configure + /// logging. It then passes that set into @c updateConfig() (or + /// @c checkConfig()). /// /// The file may contain an arbitrary number of other modules. /// diff --git a/src/lib/process/daemon.cc b/src/lib/process/daemon.cc index 4cd280d2c8..273119d66c 100644 --- a/src/lib/process/daemon.cc +++ b/src/lib/process/daemon.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,6 +20,8 @@ #include <fstream> #include <errno.h> +using namespace isc::data; + /// @brief provides default implementation for basic daemon operations /// /// This file provides stub implementations that are expected to be redefined @@ -63,11 +65,36 @@ void Daemon::handleSignal() { } } -void Daemon::configureLogger(const isc::data::ConstElementPtr& log_config, +void Daemon::relocateLogging(ConstElementPtr config, + const std::string server_name) { + ConstElementPtr logging = config->get("Logging"); + ConstElementPtr loggers; + if (logging) { + loggers = logging->get("loggers"); + ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(config); + mutable_cfg->remove("Logging"); + } + if (loggers) { + ConstElementPtr server = config->get(server_name); + ElementPtr mutable_srv = boost::const_pointer_cast<Element>(server); + mutable_srv->set("loggers", loggers); + } + while (config->size() > 1) { + ElementPtr mutable_cfg = boost::const_pointer_cast<Element>(config); + for (auto object : config->mapValue()) { + if (object.first != server_name) { + mutable_cfg->remove(object.first); + break; + } + } + } +} + +void Daemon::configureLogger(const ConstElementPtr& log_config, const ConfigPtr& storage) { if (log_config) { - isc::data::ConstElementPtr loggers = log_config->get("loggers"); + ConstElementPtr loggers = log_config->get("loggers"); if (loggers) { LogConfigParser parser(storage); parser.parseConfiguration(loggers, verbose_); @@ -227,7 +254,7 @@ Daemon::createPIDFile(int pid) { size_t Daemon::writeConfigFile(const std::string& config_file, - isc::data::ConstElementPtr cfg) const { + ConstElementPtr cfg) const { if (!cfg) { isc_throw(Unexpected, "Can't write configuration: conversion to JSON failed"); } @@ -238,7 +265,7 @@ Daemon::writeConfigFile(const std::string& config_file, } // Write the actual content using pretty printing. - isc::data::prettyPrint(cfg, out); + prettyPrint(cfg, out); size_t bytes = static_cast<size_t>(out.tellp()); diff --git a/src/lib/process/daemon.h b/src/lib/process/daemon.h index d779464814..7ef812d952 100644 --- a/src/lib/process/daemon.h +++ b/src/lib/process/daemon.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -85,9 +85,21 @@ public: /// @param verbose verbose mode (true usually enables DEBUG messages) static void loggerInit(const char* log_name, bool verbose); + /// @brief Relocate Logging configuration + /// + /// Moves the loggers entry from Logging to the server top element. + /// This method assumes the configuration is sane, e.g. the server + /// top element exists and is a map. + /// Top elements other than the server one are removed. + /// + /// @param config JSON top level configuration + /// @param server_name name of the server top element + static void relocateLogging(isc::data::ConstElementPtr config, + const std::string server_name); + /// @brief Configures logger /// - /// Applies configuration stored in "Logging" structure in the + /// Applies configuration stored in a top-level structure in the /// configuration file. This structure has a "loggers" array that /// contains 0 or more entries, each configuring one logging source /// (name, severity, debuglevel), each with zero or more outputs (file, diff --git a/src/lib/process/log_parser.cc b/src/lib/process/log_parser.cc index daf2653f17..dd3203a8fb 100644 --- a/src/lib/process/log_parser.cc +++ b/src/lib/process/log_parser.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -32,7 +32,7 @@ void LogConfigParser::parseConfiguration(const isc::data::ConstElementPtr& logge bool verbose) { verbose_ = verbose; - // Iterate over all entries in "Logging/loggers" list + // Iterate over all entries in "Server/loggers" list BOOST_FOREACH(ConstElementPtr logger, loggers->listValue()) { parseConfigEntry(logger); } diff --git a/src/lib/process/log_parser.h b/src/lib/process/log_parser.h index f7cd8c5fc8..92209bd17f 100644 --- a/src/lib/process/log_parser.h +++ b/src/lib/process/log_parser.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -39,7 +39,7 @@ namespace process { /// The data structures don't have to originate from JSON. JSON is just a /// convenient presentation syntax. /// -/// This class uses @c SrvConfig object to store logging configuration. +/// This class uses @c ConfigBase object to store logging configuration. class LogConfigParser { public: @@ -60,10 +60,10 @@ public: private: - /// @brief Parses one JSON structure in Logging/loggers" array + /// @brief Parses one JSON structure in Server/loggers" array /// /// @param entry JSON structure to be parsed - /// @brief parses one structure in Logging/loggers. + /// @brief parses one structure in Server/loggers. void parseConfigEntry(isc::data::ConstElementPtr entry); /// @brief Parses output_options structure diff --git a/src/lib/process/tests/daemon_unittest.cc b/src/lib/process/tests/daemon_unittest.cc index 22d140063e..537cae2c3d 100644 --- a/src/lib/process/tests/daemon_unittest.cc +++ b/src/lib/process/tests/daemon_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -273,6 +273,58 @@ TEST_F(DaemonTest, PIDFileCleanup) { EXPECT_EQ(errno, ENOENT); } +// Check that relocateLogging method is behaving properly with no Logging. +TEST_F(DaemonTest, relocateLoggingNoLogging) { + std::string config_txt = "{ \"myServer\": { } }"; + ConstElementPtr config = Element::fromJSON(config_txt); + ConstElementPtr expected = Element::fromJSON(config_txt); + Daemon x; + EXPECT_NO_THROW(x.relocateLogging(config, "myServer")); + EXPECT_TRUE(expected->equals(*config)); +} + +// Check that relocateLogging method is behaving properly with empty Logging. +TEST_F(DaemonTest, relocateLoggingEmptyLogging) { + std::string config_txt = + "{ \"myServer\": { },\n" + " \"Logging\": { } }"; + ConstElementPtr config = Element::fromJSON(config_txt); + std::string expected_txt = "{ \"myServer\": { } }"; + ConstElementPtr expected = Element::fromJSON(expected_txt); + Daemon x; + EXPECT_NO_THROW(x.relocateLogging(config, "myServer")); + EXPECT_TRUE(expected->equals(*config)); +} + +// Check that relocateLogging method is behaving properly. +TEST_F(DaemonTest, relocateLogging) { + std::string config_txt = + "{ \"myServer\": { },\n" + " \"Logging\": {\n" + " \"loggers\": [ ] } }"; + ConstElementPtr config = Element::fromJSON(config_txt); + std::string expected_txt = + "{ \"myServer\": {\n" + " \"loggers\": [ ] } }"; + ConstElementPtr expected = Element::fromJSON(expected_txt); + Daemon x; + EXPECT_NO_THROW(x.relocateLogging(config, "myServer")); + EXPECT_TRUE(expected->equals(*config)); +} + +// Check that relocateLogging method is behaving properly with extra objects. +TEST_F(DaemonTest, relocateLoggingExtraObjects) { + std::string config_txt = + "{ \"myServer\": { },\n" + " \"Foobar\": { } }"; + ConstElementPtr config = Element::fromJSON(config_txt); + std::string expected_txt = "{ \"myServer\": { } }"; + ConstElementPtr expected = Element::fromJSON(expected_txt); + Daemon x; + EXPECT_NO_THROW(x.relocateLogging(config, "myServer")); + EXPECT_TRUE(expected->equals(*config)); +} + // Checks that configureLogger method is behaving properly. // More dedicated tests are available for LogConfigParser class. // See logger_unittest.cc |