<commit_before>/******************************************************************************
*       SOFA, Simulation Open-Framework Architecture, development version     *
*                (c) 2006-2016 INRIA, USTL, UJF, CNRS, MGH                    *
*                                                                             *
* This library is free software; you can redistribute it and/or modify it     *
* under the terms of the GNU Lesser General Public License as published by    *
* the Free Software Foundation; either version 2.1 of the License, or (at     *
* your option) any later version.                                             *
*                                                                             *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details.                                                           *
*                                                                             *
* You should have received a copy of the GNU Lesser General Public License    *
* along with this library; if not, write to the Free Software Foundation,     *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
*******************************************************************************
*                              SOFA :: Framework                              *
*                                                                             *
* Authors: The SOFA Team (see Authors.txt)                                    *
*                                                                             *
* Contact information: <EMAIL>                             *
******************************************************************************/
#include "init.h"

#include <sofa/helper/system/console.h>

#include <iostream>

namespace sofa
{

namespace helper
{

static bool s_initialized = false;
static bool s_cleanedUp = false;

SOFA_HELPER_API void init()
{
    if (!s_initialized)
    {
        Console::init();
        s_initialized = true;
    }
}

SOFA_HELPER_API bool isInitialized()
{
    return s_initialized;
}

SOFA_HELPER_API void cleanup()
{
    if (!s_cleanedUp)
    {
        s_cleanedUp = true;
    }
}

SOFA_HELPER_API bool isCleanedUp()
{
    return s_cleanedUp;
}

SOFA_HELPER_API void printUninitializedLibraryWarning(const std::string& library,
                                                      const std::string& initFunction)
{
    std::cerr << "Warning: the " << library << " library has not been initialized ("
              << initFunction << " has never been called, see sofa/helper/init.h)" << std::endl;
}

SOFA_HELPER_API void printLibraryNotCleanedUpWarning(const std::string& library,
                                                     const std::string& cleanupFunction)
{
    std::cerr << "Warning: the " << library << " library has not been cleaned up ("
              << cleanupFunction << " has never been called, see sofa/helper/init.h)" << std::endl;
}

// Detect missing cleanup() call.
struct CleanupCheck
{
    ~CleanupCheck()
    {
        if (helper::isInitialized() && !helper::isCleanedUp())
            helper::printLibraryNotCleanedUpWarning("SofaHelper", "sofa::helper::cleanup()");
    }
} check;

} // namespace helper

} // namespace sofa
<commit_msg>using logger in helper init<commit_after>/******************************************************************************
*       SOFA, Simulation Open-Framework Architecture, development version     *
*                (c) 2006-2016 INRIA, USTL, UJF, CNRS, MGH                    *
*                                                                             *
* This library is free software; you can redistribute it and/or modify it     *
* under the terms of the GNU Lesser General Public License as published by    *
* the Free Software Foundation; either version 2.1 of the License, or (at     *
* your option) any later version.                                             *
*                                                                             *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details.                                                           *
*                                                                             *
* You should have received a copy of the GNU Lesser General Public License    *
* along with this library; if not, write to the Free Software Foundation,     *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
*******************************************************************************
*                              SOFA :: Framework                              *
*                                                                             *
* Authors: The SOFA Team (see Authors.txt)                                    *
*                                                                             *
* Contact information: <EMAIL>                             *
******************************************************************************/
#include "init.h"

#include <sofa/helper/system/console.h>
#include <sofa/helper/logging/Messaging.h>

#include <iostream>

namespace sofa
{

namespace helper
{

static bool s_initialized = false;
static bool s_cleanedUp = false;

SOFA_HELPER_API void init()
{
    if (!s_initialized)
    {
        Console::init();
        s_initialized = true;
    }
}

SOFA_HELPER_API bool isInitialized()
{
    return s_initialized;
}

SOFA_HELPER_API void cleanup()
{
    if (!s_cleanedUp)
    {
        s_cleanedUp = true;
    }
}

SOFA_HELPER_API bool isCleanedUp()
{
    return s_cleanedUp;
}

SOFA_HELPER_API void printUninitializedLibraryWarning(const std::string& library,
                                                      const std::string& initFunction)
{
    msg_warning("Helper") << "the " << library << " library has not been initialized ("
              << initFunction << " has never been called, see sofa/helper/init.h)";
}

SOFA_HELPER_API void printLibraryNotCleanedUpWarning(const std::string& library,
                                                     const std::string& cleanupFunction)
{
    msg_warning("Helper") << "the " << library << " library has not been cleaned up ("
              << cleanupFunction << " has never been called, see sofa/helper/init.h)";
}

// Detect missing cleanup() call.
struct CleanupCheck
{
    ~CleanupCheck()
    {
        if (helper::isInitialized() && !helper::isCleanedUp())
            helper::printLibraryNotCleanedUpWarning("SofaHelper", "sofa::helper::cleanup()");
    }
} check;

} // namespace helper

} // namespace sofa

{'fraction_non_alphanumeric': 0.14579465943167214, 'fraction_numerical': 0.005997429672997287, 'mean_word_length': 1.6763469621704241, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6062115', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1552, 'n_words': 506}