<commit_before>#ifndef slic3r_LOG_HPP
#define slic3r_LOG_HPP

#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <memory>
#include <locale>
#include <set>
#include <codecvt> // good until c++17


namespace Slic3r {

/// All available logging levels.
enum class log_t : uint8_t { FERR = 0, ERR = 4, WARN = 8, INFO = 16, DEBUG = 32, ALL = 255 };

inline bool operator>(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) > static_cast<uint8_t>(rhs); }
inline bool operator<(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) < static_cast<uint8_t>(rhs); }
inline bool operator>=(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) > static_cast<uint8_t>(rhs) || lhs == rhs; }
inline bool operator<=(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) < static_cast<uint8_t>(rhs) || lhs == rhs; }

/// Singleton instance implementing logging functionality in Slic3r
/// Basic functionality is stubbed in currently, may pass through to Boost::Log
/// eventually.
class _Log {
public:
    static std::unique_ptr<_Log> make_log() {
        std::unique_ptr<_Log> tmp {new _Log()};
        return tmp;
    }
    static std::unique_ptr<_Log> make_log(std::ostream& out) {
        std::unique_ptr<_Log> tmp {new _Log(out)};
        return tmp;
    }
    void fatal_error(const std::string& topic, const std::string& message);
    void fatal_error(const std::string& topic, const std::wstring& message);
    std::ostream& fatal_error(const std::string& topic);

    void error(const std::string& topic, const std::string& message);
    void error(const std::string& topic, const std::wstring& message);
    std::ostream& error(const std::string& topic);

    void info(const std::string& topic, const std::string& message);
    void info(const std::string& topic, const std::wstring& message);
    std::ostream& info(const std::string& topic);
    void debug(const std::string& topic, const std::string& message);
    void debug(const std::string& topic, const std::wstring& message);
    std::ostream& debug(const std::string& topic);
    void warn(const std::string& topic, const std::string& message);
    void warn(const std::string& topic, const std::wstring& message);
    std::ostream& warn(const std::string& topic);
    void raw(const std::string& message);
    void raw(const std::wstring& message);
    std::ostream& raw();

    template <class T>
    void debug_svg(const std::string& topic, const T& path, bool append = true);
    template <class T>
    void debug_svg(const std::string& topic, const T* path, bool append = true);

    void set_level(log_t level);
    void clear_level(log_t level);
    void set_inclusive(bool v) { this->_inclusive_levels = v; }

//    _Log(_Log const&)            = delete;
//    void operator=(_Log const&)  = delete;
private:
    std::ostream& _out;
    _Log();
    _Log(std::ostream& out);
    bool _inclusive_levels { true };
    std::set<log_t> _log_level { };

    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

    bool _has_log_level(log_t lvl);

};

/// Global log reference; initialized in Log.cpp
extern std::unique_ptr<_Log> slic3r_log;

/// Static class for referencing the various logging functions. Refers to
///
class Log {
public:
    static void fatal_error(std::string topic, std::wstring message) {
        slic3r_log->fatal_error(topic, message);
    }
    static void error(std::string topic, std::wstring message) {
        slic3r_log->error(topic, message);
    }

    static void error(std::string topic, std::string message) {
        slic3r_log->error(topic, message);
    }

    static void info(std::string topic, std::wstring message) {
        slic3r_log->info(topic, message);
    }
    static void info(std::string topic, std::string message) {
        slic3r_log->info(topic, message);
    }

    static void warn(std::string topic, std::wstring message) {
        slic3r_log->warn(topic, message);
    }
    static void warn(std::string topic, std::string message) {
        slic3r_log->warn(topic, message);
    }

    static void debug(std::string topic, std::wstring message) {
        slic3r_log->debug(topic, message);
    }
    static void debug(std::string topic, std::string message) {
        slic3r_log->debug(topic, message);
    }
    static std::ostream& error(std::string topic) {
        return slic3r_log->error(topic);
    }
    static std::ostream& debug(std::string topic) {
        return slic3r_log->debug(topic);
    }

    static std::ostream& warn(std::string topic) {
        return slic3r_log->warn(topic);
    }
    static std::ostream& info(std::string topic) {
        return slic3r_log->info(topic);
    }<commit_msg>Add doxygen comments<commit_after>#ifndef slic3r_LOG_HPP
#define slic3r_LOG_HPP

#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <memory>
#include <locale>
#include <set>
#include <codecvt> // good until c++17


namespace Slic3r {

/// All available logging levels.
enum class log_t : uint8_t { FERR = 0, ERR = 4, WARN = 8, INFO = 16, DEBUG = 32, ALL = 255 };

inline bool operator>(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) > static_cast<uint8_t>(rhs); }
inline bool operator<(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) < static_cast<uint8_t>(rhs); }
inline bool operator>=(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) > static_cast<uint8_t>(rhs) || lhs == rhs; }
inline bool operator<=(const log_t lhs, const log_t rhs) { return static_cast<uint8_t>(lhs) < static_cast<uint8_t>(rhs) || lhs == rhs; }

/// Singleton instance implementing logging functionality in Slic3r
/// Basic functionality is stubbed in currently, may pass through to Boost::Log
/// eventually.
class _Log {
public:
    static std::unique_ptr<_Log> make_log() {
        std::unique_ptr<_Log> tmp {new _Log()};
        return tmp;
    }
    static std::unique_ptr<_Log> make_log(std::ostream& out) {
        std::unique_ptr<_Log> tmp {new _Log(out)};
        return tmp;
    }
    void fatal_error(const std::string& topic, const std::string& message);
    void fatal_error(const std::string& topic, const std::wstring& message);
    std::ostream& fatal_error(const std::string& topic);

    void error(const std::string& topic, const std::string& message);
    void error(const std::string& topic, const std::wstring& message);
    std::ostream& error(const std::string& topic);

    void info(const std::string& topic, const std::string& message);
    void info(const std::string& topic, const std::wstring& message);
    std::ostream& info(const std::string& topic);
    void debug(const std::string& topic, const std::string& message);
    void debug(const std::string& topic, const std::wstring& message);
    std::ostream& debug(const std::string& topic);
    void warn(const std::string& topic, const std::string& message);
    void warn(const std::string& topic, const std::wstring& message);
    std::ostream& warn(const std::string& topic);
    void raw(const std::string& message);
    void raw(const std::wstring& message);
    std::ostream& raw();

    template <class T>
    void debug_svg(const std::string& topic, const T& path, bool append = true);
    template <class T>
    void debug_svg(const std::string& topic, const T* path, bool append = true);

    void set_level(log_t level);
    void clear_level(log_t level);
    void set_inclusive(bool v) { this->_inclusive_levels = v; }

//    _Log(_Log const&)            = delete;
//    void operator=(_Log const&)  = delete;
private:
    std::ostream& _out;
    _Log();
    _Log(std::ostream& out);
    bool _inclusive_levels { true };
    std::set<log_t> _log_level { };

    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

    bool _has_log_level(log_t lvl);

};

/// Global log reference; initialized in Log.cpp
extern std::unique_ptr<_Log> slic3r_log;

/// Static class for referencing the various logging functions. Refers to
///
class Log {
public:

    /// Logs a fatal error with Slic3r.
    /// \param topic [in] file or heading for error
    /// \param message [in] text of the logged error message
    static void fatal_error(std::string topic, std::wstring message) {
        slic3r_log->fatal_error(topic, message);
    }

    /// Logs a regular error with Slic3r.
    /// \param topic [in] file or heading for error
    /// \param message [in] text of the logged error message
    static void error(std::string topic, std::wstring message) {
        slic3r_log->error(topic, message);
    }

    /// Logs a fatal error with Slic3r.
    /// \param topic [in] file or heading for error
    /// \param message [in] text of the logged error message
    static void error(std::string topic, std::string message) {
        slic3r_log->error(topic, message);
    }

    /// Logs an informational message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \param message [in] text of the logged message
    static void info(std::string topic, std::wstring message) {
        slic3r_log->info(topic, message);
    }
    /// Logs an informational message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \param message [in] text of the logged message
    static void info(std::string topic, std::string message) {
        slic3r_log->info(topic, message);
    }

    /// Logs a warning message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \param message [in] text of the logged message
    static void warn(std::string topic, std::wstring message) {
        slic3r_log->warn(topic, message);
    }

    /// Logs a warning message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \param message [in] text of the logged message
    static void warn(std::string topic, std::string message) {
        slic3r_log->warn(topic, message);
    }

    /// Logs a debugging message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \param message [in] text of the logged message
    static void debug(std::string topic, std::wstring message) {
        slic3r_log->debug(topic, message);
    }
    /// Logs a debugging message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \param message [in] text of the logged message
    static void debug(std::string topic, std::string message) {
        slic3r_log->debug(topic, message);
    }


    /// Logs an error message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \return reference to output ostream for << chaining.
    /// \note Developer is expected to add newlines.
    static std::ostream& error(std::string topic) {
        return slic3r_log->error(topic);
    }
    /// Logs a debugging message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \return reference to output ostream for << chaining.
    /// \note Developer is expected to add newlines.
    static std::ostream& debug(std::string topic) {
        return slic3r_log->debug(topic);
    }

    /// Logs a warning message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \return reference to output ostream for << chaining.
    /// \note Developer is expected to add newlines.
    static std::ostream& warn(std::string topic) {
        return slic3r_log->warn(topic);
    }
    /// Logs an informational message with Slic3r.
    /// \param topic [in] file or heading for message
    /// \return reference to output ostream for << chaining.
    /// \note Developer is expected to add newlines.
    static std::ostream& info(std::string topic) {
        return slic3r_log->info(topic);
    }
{'fraction_non_alphanumeric': 0.12954293982466594, 'fraction_numerical': 0.008256021789088432, 'mean_word_length': 3.4541319181197876, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2099683', 'n_tokens_mistral': 3716, 'n_tokens_neox': 3649, 'n_words': 1139}