Login Page - Create Account

Support Board


Date/Time: Mon, 24 Feb 2025 18:26:47 +0000



Post From: sc. structure passed by reference as default value to all functions

[2021-03-09 20:38:31]
norvik_ - Posts: 106
namespace util{

class Logger {

public:

Logger(SCStudyInterfaceRef sc):p_Interface(&sc)

static void log(const SCDateTime& value, SCString comment = "")
{

SCString s = p_Interface->FormatDateTime(value).GetChars();

comment += s;

p_Interface->AddMessageToLog(comment, 1);

}

private:

s_sc* p_Interface;
};

or make a singleton.


class Logger
{

public:

static Logger& Instance(){static Logger l;return ;l}
void Attach(SCStudyInterfaceRef sc){p_Interface = ≻}

void log(const SCDateTime& value, SCString comment = "")
{

SCString s = p_Interface->FormatDateTime(value).GetChars();

comment += s;

p_Interface->AddMessageToLog(comment, 1);

}

private:
Logger(){}
s_sc* p_Interface;
};

and use:

Logger::Instance().Attach(sc);
Logger::Instance().log(value,comment);

Date Time Of Last Edit: 2021-03-09 20:42:24