Is it possible to restore infolog from InfologData? Consider the code
static void Job12(Args _args)
{
InfologData infologData;
;
// here we report something
error("something awful");
error("something terrible");
setprefix("scary");
warning("mouse");
// here we get infolog data
infologData = infolog.infologData();
infolog.clear(0);
// SOME CODE
// here we view infolog once again
}
what should I write instead of /开发者_StackOverflow中文版/ SOME CODE
to restore "something awful","something terrible", "scary\tmouse" into infolog from infologData?
My goal is to perform some operation, store infolog in database, and then show it to user, when they want it.
infologData can be restored in Infolog as follows:
infolog.import(infologData);
E.g.:
static void Job12(Args _args)
{
InfologData infologData;
void saveInfolog()
{
;
// here we report something
error("something awful");
error("something terrible");
setprefix("scary");
warning("mouse");
// here we get infolog data
infologData = infolog.infologData();
infolog.clear(0);
}
void restoreInfolog()
{
;
// here we view infolog once again
infolog.import(infologData);
}
;
saveInfolog();
restoreInfolog();
}
I separated saveInfolog from restoreInfolog to avoid issues with prefixes.
P.S. I prefer import() over view() for a simple reason: if you display an additional info/warning/error between saveInfolog() and restoreInfolog(), the output will be absolutely different - import() would be more appropriate in most scenarios.
The simple solution: store the returned value in a container field. Remember, do not store container fields in transaction tables, as it requires one extra disc operation per container/memo field to retrieve a record.
You may later display the value in the infolog:
infolog.view(x.InfoLogData);
You can convert the container to string:
info(Info::infoCon2str(x.InfoLogData));
精彩评论