MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / sSetLogLevel

Method sSetLogLevel

src/App/ApplicationPy.cpp:1070–1132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1068}
1069
1070PyObject* ApplicationPy::sSetLogLevel(PyObject* /*self*/, PyObject* args)
1071{
1072 char* tag {};
1073 PyObject* pcObj {};
1074 if (!PyArg_ParseTuple(args, "sO", &tag, &pcObj)) {
1075 return nullptr;
1076 }
1077 PY_TRY
1078 {
1079 int l {};
1080 if (PyUnicode_Check(pcObj)) {
1081 const char* pstr = PyUnicode_AsUTF8(pcObj);
1082 if (strcmp(pstr, "Log") == 0) {
1083 l = FC_LOGLEVEL_LOG;
1084 }
1085 else if (strcmp(pstr, "Warning") == 0) {
1086 l = FC_LOGLEVEL_WARN;
1087 }
1088 else if (strcmp(pstr, "Message") == 0) {
1089 l = FC_LOGLEVEL_MSG;
1090 }
1091 else if (strcmp(pstr, "Error") == 0) {
1092 l = FC_LOGLEVEL_ERR;
1093 }
1094 else if (strcmp(pstr, "Trace") == 0) {
1095 l = FC_LOGLEVEL_TRACE;
1096 }
1097 else if (strcmp(pstr, "Default") == 0) {
1098 l = FC_LOGLEVEL_DEFAULT;
1099 }
1100 else {
1101 Py_Error(PyExc_ValueError,
1102 "Unknown Log Level (use 'Default', 'Error', 'Warning', 'Message', 'Log', "
1103 "'Trace' or an integer)");
1104 return nullptr;
1105 }
1106 }
1107 else {
1108 l = static_cast<int>(PyLong_AsLong(pcObj));
1109 }
1110 GetApplication()
1111 .GetParameterGroupByPath("User parameter:BaseApp/LogLevels")
1112 ->SetInt(tag, l);
1113 if (strcmp(tag, "Default") == 0) {
1114#ifndef FC_DEBUG
1115 if (l >= 0) {
1116 Base::Console().setDefaultLogLevel(l);
1117 }
1118#endif
1119 }
1120 else if (strcmp(tag, "DebugDefault") == 0) {
1121#ifdef FC_DEBUG
1122 if (l >= 0) {
1123 Base::Console().setDefaultLogLevel(l);
1124 }
1125#endif
1126 }
1127 else {

Callers

nothing calls this directly

Calls 3

SetIntMethod · 0.80
getLogLevelMethod · 0.80

Tested by

no test coverage detected