Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introducing an env var ARTDAQ_RUN_NUMBER #50

Open
pavel1murat opened this issue Nov 19, 2023 · 0 comments
Open

introducing an env var ARTDAQ_RUN_NUMBER #50

pavel1murat opened this issue Nov 19, 2023 · 0 comments

Comments

@pavel1murat
Copy link
Contributor

to allow encoding of run numbers into the log file names, I propose the following patch to artdaq_core/artdaq-core/Utilities/configureMessageFacility.cc

Modulo the line alignment, the patch introduces an env var ARTDAQ_RUN_NUMBER, and if that is defined, encodes it in the log file name. That will allow us to avoid using multiple log-related symlinks in the online environment

diff --git a/artdaq-core/Utilities/configureMessageFacility.cc b/artdaq-core/Utilities/configureMessageFacility.cc
index 59a793c..b1cd0e7 100644
--- a/artdaq-core/Utilities/configureMessageFacility.cc
+++ b/artdaq-core/Utilities/configureMessageFacility.cc
@@ -29,10 +29,15 @@ fhicl::ParameterSet make_pset(std::string const& config_str)
 std::string artdaq::generateMessageFacilityConfiguration(char const* progname, bool useConsole, bool printDebug, char const* fileExtraName)
 {
        std::string logPathProblem;
-       char* logRootString = getenv("ARTDAQ_LOG_ROOT");
-       char* logFhiclCode = getenv("ARTDAQ_LOG_FHICL");
+//-----------------------------------------------------------------------------
+// get environment variables
+//-----------------------------------------------------------------------------
+       char* logRootString         = getenv("ARTDAQ_LOG_ROOT");
+       char* logFhiclCode          = getenv("ARTDAQ_LOG_FHICL");
        char* artdaqMfextensionsDir = getenv("ARTDAQ_MFEXTENSIONS_DIR");
-       char* useMFExtensionsS = getenv("ARTDAQ_MFEXTENSIONS_ENABLED");
+       char* useMFExtensionsS      = getenv("ARTDAQ_MFEXTENSIONS_ENABLED");
+       char* run_number            = getenv("ARTDAQ_RUN_NUMBER");
+
        bool useMFExtensions = false;
        if (useMFExtensionsS != nullptr && !(strncmp(useMFExtensionsS, "0", 1) == 0))
        {
@@ -108,8 +113,18 @@ std::string artdaq::generateMessageFacilityConfiguration(char const* progname, b
        {
                ss << " file: {";
                ss << R"( type: "GenFile" threshold: "DEBUG" seperator: "-")";
-               ss << " pattern: \"" << progname << fileExtraName << "-%?H%t-%p.log"
-                  << "\"";
+    if (run_number == nullptr) {
+      ss << " pattern: \"" << progname << fileExtraName << "-%?H%t-%p.log" << "\"";
+    }
+    else {
+//-----------------------------------------------------------------------------
+// Mu2e case: run number is defined
+//-----------------------------------------------------------------------------
+      char c[10];
+      sprintf(c,"%06i",std::stoi(run_number));
+      ss << " pattern: \"" << progname << "-" << c << fileExtraName << "-%?H%t-%p.log" << "\"";
+    }
+
                ss << " timestamp_pattern: \"%Y%m%d%H%M%S\"";
                ss << " directory: \"" << logfileDir << "\"";
                ss << " append : false";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant