comparison Sources/PythonLock.cpp @ 28:b2bbb516056e

The "Calling Python..." info logs are disabled if "PythonVerbose" is "false"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 27 Apr 2020 07:59:35 +0200
parents 952e969a2240
children fd58eb5749ed
comparison
equal deleted inserted replaced
27:ec7860ac40e9 28:b2bbb516056e
30 static PyThreadState* interpreterState_ = NULL; 30 static PyThreadState* interpreterState_ = NULL;
31 static PythonLock::ModuleFunctionsInstaller moduleFunctions_ = NULL; 31 static PythonLock::ModuleFunctionsInstaller moduleFunctions_ = NULL;
32 static PythonLock::ModuleClassesInstaller moduleClasses_ = NULL; 32 static PythonLock::ModuleClassesInstaller moduleClasses_ = NULL;
33 static std::string moduleName_; 33 static std::string moduleName_;
34 static std::string exceptionName_; 34 static std::string exceptionName_;
35 static bool verbose_ = false;
35 36
36 37
37 struct module_state 38 struct module_state
38 { 39 {
39 PyObject *exceptionClass_ = NULL; 40 PyObject *exceptionClass_ = NULL;
343 Py_UnbufferedStdioFlag = 1; // Write immediately to stdout after "sys.stdout.flush()" (only in Python 3.x) 344 Py_UnbufferedStdioFlag = 1; // Write immediately to stdout after "sys.stdout.flush()" (only in Python 3.x)
344 #endif 345 #endif
345 346
346 Py_InspectFlag = 1; // Don't exit the Orthanc process on Python error 347 Py_InspectFlag = 1; // Don't exit the Orthanc process on Python error
347 348
349 verbose_ = verbose;
348 if (verbose) 350 if (verbose)
349 { 351 {
350 Py_VerboseFlag = 1; 352 Py_VerboseFlag = 1;
351 } 353 }
352 354
467 { 469 {
468 PyErr_SetString(state->exceptionClass_, message); 470 PyErr_SetString(state->exceptionClass_, message);
469 } 471 }
470 } 472 }
471 } 473 }
474
475
476 void PythonLock::LogCall(const std::string& message)
477 {
478 /**
479 * For purity, this function should lock the global "mutex_", but
480 * "verbose_" cannot change after the initial call to
481 * "GlobalInitialize()".
482 **/
483
484 if (verbose_)
485 {
486 OrthancPlugins::LogInfo(message);
487 }
488 }