comparison OrthancServer/Sources/main.cpp @ 4270:251a8b07fa37

logging categories
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Nov 2020 18:45:50 +0100
parents 64f57c9d5f79
children 0034f855c023
comparison
equal deleted inserted replaced
4269:c7bd2f21ccc3 4270:251a8b07fa37
1493 { 1493 {
1494 return ConfigurePlugins(argc, argv, upgradeDatabase, loadJobsFromDatabase); 1494 return ConfigurePlugins(argc, argv, upgradeDatabase, loadJobsFromDatabase);
1495 } 1495 }
1496 1496
1497 1497
1498 static void SetLoggingCategories(Logging::LogLevel level,
1499 const std::string& lst)
1500 {
1501 std::vector<std::string> categories;
1502 Toolbox::TokenizeString(categories, lst, ':');
1503 for (size_t i = 0; i < categories.size(); i++)
1504 {
1505 Logging::SetCategoryEnabled(level, Logging::StringToCategory(categories[i]), true);
1506 }
1507 }
1508
1509
1498 static bool DisplayPerformanceWarning() 1510 static bool DisplayPerformanceWarning()
1499 { 1511 {
1500 (void) DisplayPerformanceWarning; // Disable warning about unused function 1512 (void) DisplayPerformanceWarning; // Disable warning about unused function
1501 LOG(WARNING) << "Performance warning: Non-release build, runtime debug assertions are turned on"; 1513 LOG(WARNING) << "Performance warning: Non-release build, runtime debug assertions are turned on";
1502 return true; 1514 return true;
1561 } 1573 }
1562 else if (argument == "--trace") 1574 else if (argument == "--trace")
1563 { 1575 {
1564 Logging::EnableTraceLevel(true); 1576 Logging::EnableTraceLevel(true);
1565 } 1577 }
1578 else if (boost::starts_with(argument, "--verbose=")) // New in Orthanc 1.8.1
1579 {
1580 SetLoggingCategories(Logging::LogLevel_INFO, argument.substr(10));
1581 }
1582 else if (boost::starts_with(argument, "--trace=")) // New in Orthanc 1.8.1
1583 {
1584 SetLoggingCategories(Logging::LogLevel_TRACE, argument.substr(8));
1585 }
1566 else if (boost::starts_with(argument, "--logdir=")) 1586 else if (boost::starts_with(argument, "--logdir="))
1567 { 1587 {
1568 // TODO WHAT IS THE ENCODING? 1588 // TODO WHAT IS THE ENCODING?
1569 std::string directory = argument.substr(9); 1589 const std::string directory = argument.substr(9);
1570 1590
1571 try 1591 try
1572 { 1592 {
1573 Logging::SetTargetFolder(directory); 1593 Logging::SetTargetFolder(directory);
1574 } 1594 }
1580 } 1600 }
1581 } 1601 }
1582 else if (boost::starts_with(argument, "--logfile=")) 1602 else if (boost::starts_with(argument, "--logfile="))
1583 { 1603 {
1584 // TODO WHAT IS THE ENCODING? 1604 // TODO WHAT IS THE ENCODING?
1585 std::string file = argument.substr(10); 1605 const std::string file = argument.substr(10);
1586 1606
1587 try 1607 try
1588 { 1608 {
1589 Logging::SetTargetFile(file); 1609 Logging::SetTargetFile(file);
1590 } 1610 }