1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author : Konstantin Leontev (OpenCascade)
25 #include "libSALOMELog.hxx"
33 // ============================================================================
35 * Called by any log message macros to decide about log output in Release and
36 * Debug mode dynamically rely on SALOME_VERBOSE environment variable.
37 * Checks SALOME_VERBOSE only on the very first call and returns cached result
38 * for all followed calls.
39 * Returns true if SALOME_VERBOSE is positioned and not empty and if its
40 * numeric value greater than 0.
42 // ============================================================================
44 bool VerbosityActivated()
46 auto isEnvVarSet = []() -> bool
48 const char* envVar = std::getenv("SALOME_VERBOSE");
50 if (envVar && (envVar[0] != '\0'))
54 const long long numValue = std::stoll(envVar);
57 catch(const std::exception& e)
59 std::cerr << e.what() << '\n';
66 static const bool isActivated = isEnvVarSet();