179 .Add(
"tool_name",
"XYZ")
180 .Add(
"tool_version", 2)
181 .Add(
"one_more_parameter", 123.45));
214 params1.
Add(
"p1",
"v1");
215 reporter1.
Send(params1);
216 params2.
Add(
"p2",
"v2");
217 reporter2.
Send(params2);
220 params1.
Add(
"p1",
"new value for p1");
221 reporter1.
Send(params1);
243 CMyJob(
int id = 0) : m_ID(
id) {};
252 state_str =
"Queued";
256 state_str =
"Running";
266 state_str =
"Failed";
270 state_str =
"Canceled";
274 state_str =
"Rejected";
279 cout <<
"callback: job " << m_ID <<
" -> " << state_str << endl << flush;
304 for (
int i = 1;
i < 40;
i++) {
309 job.Add(
"p2",
"v" + std::to_string(
i));
326 int main(
int argc,
const char* argv[])
CTimeout – Timeout interval.
void Pattern_2_MultipleReporters()
Custom reporters.
void ConfigureAPI()
Global API configuration example.
void Pattern_1_SimpleMacro()
Simplest way to report – use provided macro.
int Run()
Run the application.
void Pattern_3_StatusControl()
Advanced reporting method with custom jobs and reporting status control.
void Init()
Initialize the application.
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
@ eDS_Default
Try standard log file (app.name + ".log") in /log/, use stderr on failure.
@ eDiag_Warning
Warning message.
void Warning(CExceptionArgs_Base &args)
#define NCBI_REPORT_USAGE_START
Enable usage statistics reporting (globally for all reporters).
static void SetMaxQueueSize(unsigned n)
Declare the maximum reporting jobs queue size per reporter.
static void SetAppName(const string &name)
Set application name for the usage reporters.
static void SetTimeout(const CTimeout &timeout)
Set timeout for connection.
static void SetRetries(int retries)
Set muximum number of retries in case of error reporting.
void Finish(void)
Finish reporting for the current reporting object.
void Send(void)
Report usage statistics (asynchronously), default parameters.
#define NCBI_REPORT_USAGE(event,...)
Convenience macro to log "jsevent" usage statistics (asynchronously).
static void SetAppVersion(const string &version)
Set application version for the usage reporter(s).
#define NCBI_REPORT_USAGE_WAIT
Wait until all reports via NCBI_REPORT_USAGE will be processed.
static void SetDefaultParameters(TWhat what=fDefault)
Set default reporting parameters.
CUsageReportParameters & Add(const string &name, const string &value)
Add argument Name must contain only alphanumeric chars or '_'.
#define NCBI_REPORT_USAGE_FINISH
Finishing reporting via NCBI_REPORT_USAGE and global usage reporter,.
static CUsageReport & Instance(void)
Return global instance of CUsageReport.
static void SetEnabled(bool enable=true)
Enable or disable usage statistics reporting globally for all reporters.
static void SetURL(const string &url)
Change CGI URL for reporting usage statistics.
void Wait(EWait how=eAlways, CTimeout timeout=CTimeout(CTimeout::eDefault))
Wait until all queued jobs starts to process and queue is empty.
static bool CheckConnection()
Check that connection to reporting URL can be established.
@ fNone
No defaults, all parameters should be specified via CUsageReportParameters directly.
@ fAppVersion
Application version ("version")
@ fHost
Host name ("host")
@ fAppName
Application name ("appname")
@ eQueued
Added to queue (sending temporary postpones)
@ eFailed
Result: send failed.
@ eCanceled
Result: canceled / removed from queue.
@ eRejected
Result: rejected / too many requests.
@ eCompleted
Result: successfully sent.
int main(int argc, const char *argv[])
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define NCBI_APP_SET_VERSION(major, minor, patch)