Replaced Json parser with a custom one (optims+compact output)

This commit is contained in:
emeric
2023-10-20 15:22:00 +02:00
parent 4562e0368a
commit d86260ba2d
13 changed files with 316 additions and 181 deletions
+43 -41
View File
@@ -26,33 +26,33 @@
enum class Severity
{
FATAL,
ERROR,
WARNING,
INFO,
DEBUG,
FATAL,
ERROR,
WARNING,
INFO,
DEBUG,
};
enum class Module
{
API_SUBSONIC,
AUTH,
AV,
CHILDPROCESS,
COVER,
DB,
DBUPDATER,
FEATURE,
HTTP,
MAIN,
METADATA,
REMOTE,
SCROBBLING,
SERVICE,
RECOMMENDATION,
TRANSCODE,
UI,
UTILS,
API_SUBSONIC,
AUTH,
AV,
CHILDPROCESS,
COVER,
DB,
DBUPDATER,
FEATURE,
HTTP,
MAIN,
METADATA,
REMOTE,
SCROBBLING,
SERVICE,
RECOMMENDATION,
TRANSCODE,
UI,
UTILS,
};
const char* getModuleName(Module mod);
@@ -61,30 +61,32 @@ const char* getSeverityName(Severity sev);
class Logger;
class Log
{
public:
Log(Logger* logger, Module module, Severity severity);
~Log();
public:
Log(Logger* logger, Module module, Severity severity);
~Log();
Module getModule() const { return _module; }
Severity getSeverity() const { return _severity; }
std::string getMessage() const;
Module getModule() const { return _module; }
Severity getSeverity() const { return _severity; }
std::string getMessage() const;
std::ostringstream& getOstream() { return _oss; }
std::ostringstream& getOstream() { return _oss; }
private:
Module _module;
Severity _severity;
std::ostringstream _oss;
Logger* _logger {};
private:
Log(const Log&) = delete;
Log& operator=(const Log&) = delete;
Module _module;
Severity _severity;
std::ostringstream _oss;
Logger* _logger{};
};
class Logger
{
public:
virtual ~Logger() = default;
virtual void processLog(const Log& log) = 0;
public:
virtual ~Logger() = default;
virtual void processLog(const Log& log) = 0;
};
#define LMS_LOG(module, severity) Log(Service<Logger>::get(), Module::module, Severity::severity).getOstream()
#define LMS_LOG_EX(module, severity) Log(Service<Logger>::get(), module, severity).getOstream()
#define LMS_LOG(module, severity) Log{Service<Logger>::get(), Module::module, Severity::severity}.getOstream()
#define LMS_LOG_EX(module, severity) Log{Service<Logger>::get(), module, severity}.getOstream()
+2 -1
View File
@@ -83,7 +83,8 @@ namespace StringUtils {
[[nodiscard]] std::string replaceInString(std::string_view str, const std::string& from, const std::string& to);
[[nodiscard]] std::string jsEscape(const std::string& str);
[[nodiscard]] std::string jsEscape(std::string_view str);
void writeJSEscapedString(std::ostream& os, std::string_view str);
[[nodiscard]] std::string escapeString(std::string_view str, std::string_view charsToEscape, char escapeChar);