-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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"
- Loading branch information
Showing
6 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/sonic-yang-models/tests/yang_model_tests/tests/logger.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT": { | ||
"desc": "LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT_1 no failure." | ||
}, | ||
"LOGGER_WRONG_LOGLEVEL": { | ||
"desc": "LOGGER_WRONG_LOGLEVEL pattern failure.", | ||
"eStr": ["wrong", "LOGLEVEL"] | ||
}, | ||
"LOGGER_WRONG_LOGOUTPUT": { | ||
"desc": "LOGGER_WRONG_LOGOUTPUT pattern failure.", | ||
"eStr": ["wrong", "LOGOUTPUT"] | ||
}, | ||
"LOGGER_MANDATORY_LOGLEVEL": { | ||
"desc": "LOGGER_MANDATORY_LOGOUTPUT no logoutput.", | ||
"estr": ["LOGLEVEL"], | ||
"eStrKey": "Mandatory" | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/sonic-yang-models/tests/yang_model_tests/tests_config/logger.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT": { | ||
"sonic-logger:sonic-logger": { | ||
"sonic-logger:LOGGER": { | ||
"LOGGER_LIST": [{ | ||
"name": "orchagent", | ||
"LOGLEVEL": "NOTICE", | ||
"LOGOUTPUT": "SYSLOG" | ||
}, | ||
{ | ||
"name": "syncd", | ||
"LOGLEVEL": "DEBUG", | ||
"LOGOUTPUT": "STDOUT" | ||
}, | ||
{ | ||
"name": "SAI_API_LAG", | ||
"LOGLEVEL": "SAI_LOG_LEVEL_ERROR", | ||
"LOGOUTPUT": "STDERR" | ||
}] | ||
} | ||
} | ||
}, | ||
"LOGGER_WRONG_LOGLEVEL": { | ||
"sonic-logger:sonic-logger": { | ||
"sonic-logger:LOGGER": { | ||
"LOGGER_LIST": [{ | ||
"name": "orchagent", | ||
"LOGLEVEL": "wrong", | ||
"LOGOUTPUT": "SYSLOG" | ||
}] | ||
} | ||
} | ||
}, | ||
"LOGGER_WRONG_LOGOUTPUT": { | ||
"sonic-logger:sonic-logger": { | ||
"sonic-logger:LOGGER": { | ||
"LOGGER_LIST": [{ | ||
"name": "orchagent", | ||
"LOGLEVEL": "NOTICE", | ||
"LOGOUTPUT": "wrong" | ||
}] | ||
} | ||
} | ||
}, | ||
"LOGGER_MANDATORY_LOGLEVEL": { | ||
"sonic-logger:sonic-logger": { | ||
"sonic-logger:LOGGER": { | ||
"LOGGER_LIST": [{ | ||
"name": "orchagent", | ||
"LOGOUTPUT": "SYSLOG" | ||
}] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
module sonic-logger{ | ||
|
||
yang-version 1.1; | ||
|
||
namespace "http://github.com/Azure/sonic-logger"; | ||
prefix logger; | ||
|
||
import sonic-types { | ||
prefix stypes; | ||
} | ||
|
||
description "Logger Table yang Module for SONiC"; | ||
|
||
typedef swss_loglevel { | ||
type enumeration { | ||
enum EMERG; | ||
enum ALERT; | ||
enum CRIT; | ||
enum ERROR; | ||
enum WARN; | ||
enum NOTICE; | ||
enum INFO; | ||
enum DEBUG; | ||
} | ||
} | ||
|
||
typedef sai_loglevel { | ||
type enumeration { | ||
enum SAI_LOG_LEVEL_CRITICAL; | ||
enum SAI_LOG_LEVEL_ERROR; | ||
enum SAI_LOG_LEVEL_WARN; | ||
enum SAI_LOG_LEVEL_NOTICE; | ||
enum SAI_LOG_LEVEL_INFO; | ||
enum SAI_LOG_LEVEL_DEBUG; | ||
} | ||
} | ||
|
||
container sonic-logger { | ||
|
||
container LOGGER { | ||
|
||
description "Logger table in config_db.json"; | ||
|
||
list LOGGER_LIST { | ||
|
||
key "name"; | ||
|
||
leaf name { | ||
description "Component name in LOGGER table (example for component: orchagent, Syncd, SAI components)."; | ||
type string; | ||
} | ||
|
||
leaf LOGLEVEL { | ||
description "The log verbosity for the component"; | ||
mandatory true; | ||
type union { | ||
type swss_loglevel; | ||
type sai_loglevel; | ||
} | ||
} | ||
|
||
leaf LOGOUTPUT { | ||
type enumeration { | ||
enum SYSLOG; | ||
enum STDOUT; | ||
enum STDERR; | ||
} | ||
default SYSLOG; | ||
} | ||
}/* end of list LOGGER_LIST */ | ||
}/* end of LOGGER container */ | ||
}/* end of sonic-logger container */ | ||
}/* end of sonic-logger module */ |