PanPhaseField SDK
plugin_log_utility::PFPLUGIN_LOG Class Reference

User-defined log file. More...

#include <pfm_writers.h>

Public Member Functions

 PFPLUGIN_LOG (string LOG_PATH, string file_name, string calc_name)
 
void write (string val)
 
void write (string key, double val, int indent=0)
 
void write_cal (shared_ptr< P_Point > cal_pt)
 

Detailed Description

User-defined log file.

This class can be used to generate log files to track the progress of the simulation. It will be very helpful in debugging during plugin development. In the plugin class, you can declare a pointer to this class as

plugin_log_utility::PFPLUGIN* txt_log;

Then it can allocated in the load_arguments() method as:

PF_ARGS_Interpreter args_ext(m_args); // arguments interpretor
string logfile_name(args_ext.calc_name() + ".txt");
string logfile_path( args_ext.vtk_dir() + "/");
txt_log = new plugin_log_utility::PFPLUGIN_LOG(logfile_path, logfile_name, args_ext.app_name());
A C++ interpretor for phase-field model arguments PF_ARGS.
Definition: PanPhaseFieldArguments.h:227
User-defined log file.
Definition: pfm_writers.h:1581

Then anywhere in the code, custom log messages can be printed using the following syntax

txt_log->write("String can be printed like this");
double value=0.5;
txt_log->write("Variable value",value);

Also, kindly delete its memory at the end of the simulation in the destructor of the plugin.

if(txt_log!=NULL) {
delete txt_log;
txt_log=NULL;
}

Constructor & Destructor Documentation

◆ PFPLUGIN_LOG()

plugin_log_utility::PFPLUGIN_LOG::PFPLUGIN_LOG ( string  LOG_PATH,
string  file_name,
string  calc_name 
)
inline

Constructor with log path, file name, and calculation name

Parameters
[in]LOG_PATHthe path of log file
[in]file_namethe name of log file
[in]calc_namethe name of calculation

Member Function Documentation

◆ write() [1/2]

void plugin_log_utility::PFPLUGIN_LOG::write ( string  val)
inline

Write a string

Parameters
[in]valthe string to be written

◆ write() [2/2]

void plugin_log_utility::PFPLUGIN_LOG::write ( string  key,
double  val,
int  indent = 0 
)
inline

Write a pair of key and value, with a line indent with size of indent

Parameters
[in]keythe string key to be written
[in]valthe value to be written
[in]indentthe line indent (default=0)

◆ write_cal()

void plugin_log_utility::PFPLUGIN_LOG::write_cal ( shared_ptr< P_Point >  cal_pt)
inline

Write a P_Point to log file

Parameters
[in]cal_ptthe Pandat P_Point

The documentation for this class was generated from the following file: