Skip to content

Commit 6bed69a

Browse files
authored
Add a yang model for the new "Logger" table in the CONFIG DB (#12067)
- Why I did it Add the ability to the user to save the loglevel and make it persistent to reboot. - How I did it Move the logger tables from the LOGLEVEL DB to the CONFIG DB. Add new yang model to verify the new config schema. - How to verify it 1. change the orchagent loglevel (for example) -> swssloglevel -c orchagent -l DEBUG 2. save the loglevel -> run config save 3. reboot 4. verify that the orchagent log level is still DEBUG ->run run redis-cli -n 4 hgetall "LOGGER|orchagent"
1 parent d1df284 commit 6bed69a

File tree

6 files changed

+191
-0
lines changed

6 files changed

+191
-0
lines changed

src/sonic-yang-models/doc/Configuration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Table of Contents
5858
* [VOQ Inband Interface](#voq-inband-interface)
5959
* [VXLAN](#vxlan)
6060
* [Virtual router](#virtual-router)
61+
* [LOGGER](#logger)
6162
* [WRED_PROFILE](#wred_profile)
6263
* [PASSWORD_HARDENING](#password_hardening)
6364
* [SYSTEM_DEFAULTS table](#systemdefaults-table)
@@ -1705,6 +1706,34 @@ The packet action could be:
17051706
}
17061707
}
17071708
```
1709+
1710+
### Logger
1711+
1712+
In this table, the loglevel and logoutput of the components are defined. Each component
1713+
will have the component name as its key; and LOGLEVEL and LOGOUTPUT as attributes.
1714+
The LOGLEVEL attribute will define the verbosity of the component.
1715+
The LOGOUTPUT attribute will define the file of printing the logs.
1716+
1717+
```
1718+
{
1719+
"LOGGER": {
1720+
"orchagent": {
1721+
"LOGLEVEL": "NOTICE",
1722+
"LOGOUTPUT": "SYSLOG"
1723+
},
1724+
"syncd": {
1725+
"LOGLEVEL": "DEBUG",
1726+
"LOGOUTPUT": "STDOUT"
1727+
},
1728+
"SAI_API_LAG": {
1729+
"LOGLEVEL": "ERROR",
1730+
"LOGOUTPUT": "STDERR"
1731+
}
1732+
}
1733+
}
1734+
1735+
```
1736+
17081737
### PASSWORD_HARDENING
17091738

17101739
Password Hardening, a user password is the key credential used in order to verify the user accessing the switch and acts as the first line of defense in regards to securing the switch. PASSWORD_HARDENING - support the enforce strong policies.

src/sonic-yang-models/setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def run(self):
169169
'./yang-models/sonic-peer-switch.yang',
170170
'./yang-models/sonic-pfc-priority-queue-map.yang',
171171
'./yang-models/sonic-pfc-priority-priority-group-map.yang',
172+
'./yang-models/sonic-logger.yang',
172173
'./yang-models/sonic-port-qos-map.yang',
173174
'./yang-models/sonic-static-route.yang',
174175
'./yang-models/sonic-macsec.yang']),
@@ -234,6 +235,7 @@ def run(self):
234235
'./cvlyang-models/sonic-tc-queue-map.yang',
235236
'./cvlyang-models/sonic-pfc-priority-queue-map.yang',
236237
'./cvlyang-models/sonic-pfc-priority-priority-group-map.yang',
238+
'./cvlyang-models/sonic-logger.yang',
237239
'./cvlyang-models/sonic-port-qos-map.yang',
238240
'./cvlyang-models/sonic-static-route.yang',
239241
'./cvlyang-models/sonic-macsec.yang']),

src/sonic-yang-models/tests/files/sample_config_db.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,20 @@
837837
"tpid": "0x8100"
838838
}
839839
},
840+
"LOGGER": {
841+
"orchagent": {
842+
"LOGLEVEL": "NOTICE",
843+
"LOGOUTPUT": "SYSLOG"
844+
},
845+
"syncd": {
846+
"LOGLEVEL": "NOTICE",
847+
"LOGOUTPUT": "SYSLOG"
848+
},
849+
"SAI_API_LAG": {
850+
"LOGLEVEL": "SAI_LOG_LEVEL_NOTICE",
851+
"LOGOUTPUT": "SYSLOG"
852+
}
853+
},
840854
"ACL_TABLE": {
841855
"V4-ACL-TABLE": {
842856
"type": "L3",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT": {
3+
"desc": "LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT_1 no failure."
4+
},
5+
"LOGGER_WRONG_LOGLEVEL": {
6+
"desc": "LOGGER_WRONG_LOGLEVEL pattern failure.",
7+
"eStr": ["wrong", "LOGLEVEL"]
8+
},
9+
"LOGGER_WRONG_LOGOUTPUT": {
10+
"desc": "LOGGER_WRONG_LOGOUTPUT pattern failure.",
11+
"eStr": ["wrong", "LOGOUTPUT"]
12+
},
13+
"LOGGER_MANDATORY_LOGLEVEL": {
14+
"desc": "LOGGER_MANDATORY_LOGOUTPUT no logoutput.",
15+
"estr": ["LOGLEVEL"],
16+
"eStrKey": "Mandatory"
17+
}
18+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT": {
3+
"sonic-logger:sonic-logger": {
4+
"sonic-logger:LOGGER": {
5+
"LOGGER_LIST": [{
6+
"name": "orchagent",
7+
"LOGLEVEL": "NOTICE",
8+
"LOGOUTPUT": "SYSLOG"
9+
},
10+
{
11+
"name": "syncd",
12+
"LOGLEVEL": "DEBUG",
13+
"LOGOUTPUT": "STDOUT"
14+
},
15+
{
16+
"name": "SAI_API_LAG",
17+
"LOGLEVEL": "SAI_LOG_LEVEL_ERROR",
18+
"LOGOUTPUT": "STDERR"
19+
}]
20+
}
21+
}
22+
},
23+
"LOGGER_WRONG_LOGLEVEL": {
24+
"sonic-logger:sonic-logger": {
25+
"sonic-logger:LOGGER": {
26+
"LOGGER_LIST": [{
27+
"name": "orchagent",
28+
"LOGLEVEL": "wrong",
29+
"LOGOUTPUT": "SYSLOG"
30+
}]
31+
}
32+
}
33+
},
34+
"LOGGER_WRONG_LOGOUTPUT": {
35+
"sonic-logger:sonic-logger": {
36+
"sonic-logger:LOGGER": {
37+
"LOGGER_LIST": [{
38+
"name": "orchagent",
39+
"LOGLEVEL": "NOTICE",
40+
"LOGOUTPUT": "wrong"
41+
}]
42+
}
43+
}
44+
},
45+
"LOGGER_MANDATORY_LOGLEVEL": {
46+
"sonic-logger:sonic-logger": {
47+
"sonic-logger:LOGGER": {
48+
"LOGGER_LIST": [{
49+
"name": "orchagent",
50+
"LOGOUTPUT": "SYSLOG"
51+
}]
52+
}
53+
}
54+
}
55+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module sonic-logger{
2+
3+
yang-version 1.1;
4+
5+
namespace "http://github.com/Azure/sonic-logger";
6+
prefix logger;
7+
8+
import sonic-types {
9+
prefix stypes;
10+
}
11+
12+
description "Logger Table yang Module for SONiC";
13+
14+
typedef swss_loglevel {
15+
type enumeration {
16+
enum EMERG;
17+
enum ALERT;
18+
enum CRIT;
19+
enum ERROR;
20+
enum WARN;
21+
enum NOTICE;
22+
enum INFO;
23+
enum DEBUG;
24+
}
25+
}
26+
27+
typedef sai_loglevel {
28+
type enumeration {
29+
enum SAI_LOG_LEVEL_CRITICAL;
30+
enum SAI_LOG_LEVEL_ERROR;
31+
enum SAI_LOG_LEVEL_WARN;
32+
enum SAI_LOG_LEVEL_NOTICE;
33+
enum SAI_LOG_LEVEL_INFO;
34+
enum SAI_LOG_LEVEL_DEBUG;
35+
}
36+
}
37+
38+
container sonic-logger {
39+
40+
container LOGGER {
41+
42+
description "Logger table in config_db.json";
43+
44+
list LOGGER_LIST {
45+
46+
key "name";
47+
48+
leaf name {
49+
description "Component name in LOGGER table (example for component: orchagent, Syncd, SAI components).";
50+
type string;
51+
}
52+
53+
leaf LOGLEVEL {
54+
description "The log verbosity for the component";
55+
mandatory true;
56+
type union {
57+
type swss_loglevel;
58+
type sai_loglevel;
59+
}
60+
}
61+
62+
leaf LOGOUTPUT {
63+
type enumeration {
64+
enum SYSLOG;
65+
enum STDOUT;
66+
enum STDERR;
67+
}
68+
default SYSLOG;
69+
}
70+
}/* end of list LOGGER_LIST */
71+
}/* end of LOGGER container */
72+
}/* end of sonic-logger container */
73+
}/* end of sonic-logger module */

0 commit comments

Comments
 (0)