7.1Writing a log in a file
Proud::CLogWriter class writes a log in a file.
As explained in The internal link is invalid., this function runs asynchronously.
The general usage is guided in below.
// Generate CLogWriter. CAutoPtr<Proud::CLogWriter> logwriter; logwriter.Attach(Proud::CLogWriter::New(L"log.txt")); // Let's make a log with two provided WriteLine function. logwriter->WriteLine( Proud::TraceID::TID_System, L"시스템로그 입니다. ); logwriter->WriteLine( "%d번째 로그입니다.", 1 ); /* Let's change it to a new log file. If generating a new file fails, you can exceptionally manage it with Proud::Exception. */ logwriter->SetFileName(L"log2.txt);
7.2Recording a log in database
Proud::CDbLogWriter class helps recording a log in DB.
this function runs asynchronously.
In order to use this, you need to generate LogTable by executing LogTable.sql from Sample/DbmsSchema. How to build DBMS is guided in 샘플 데이터베이스 구축하기e.
The general usage is as followed..
// This function will handle error class CTestLogWriterDelegate : public ILogWriterDelegate { virtual void OnLogWriterException(Proud::AdoException& Err) override { // ... } }; CTestLogWriterDelegate g_dblogDelegate; void main() { // ... // Fill in a value in CDbLogParameter. Proud::CDbLogParameter dbparam; dbparam.m_dbmsConnectionString = L"Data Source=localhost;Database=Log-Test;Trusted_Connection=yes"; dbparam.m_loggerName = L"LoggerName"; dbparam.m_dbLogTableName = L"DbLog"; // Generate CDbLogWriter. CAutoPtr<Proud::CDbLogWriter> dbLogWriter; dbLogWriter.Attach(Proud::CDbLogWriter::New(dbparam, &g_dblogDelegate)); // Let's add a new field that isn't supported by ProudNet. // WARNING!! When adding a custom field, you must generate a field in Log-Test Table of DBMS. // After making TestField in DBMS and setting int for datatype, generate CPropNode as shown in below and add it to WriteLine. Proud::CProperty newnode; Proud::String TestField = L"TestField"; Proud::CVariant TestValue = 123; newnode.Add(TestField, TestValue); dbLogWriter->WriteLine(L"Contents of Log", &newnode); // ... }