Esempio n. 1
0
Init::~Init()
{
  //
  // Write out the Regal configuration file as JSON
  //

#if !REGAL_NO_JSON
  if (Config::configFile.length())
  {
    Json::Output jo;
    jo.object();
      jo.object("regal");
        Config::writeJSON(jo);
        Logging::writeJSON(jo);
      jo.end();
    jo.end();

    FILE *f = fopen(Config::configFile.c_str(),"wt");
    if (f)
    {
      string tmp = jo.str();
      fwrite(tmp.c_str(),1,tmp.length(),f);
      fclose(f);
      Info("Regal configuration written to ",Config::configFile);
    }
    else
    {
      Warning("Regal configuration could not be written to ",Config::configFile);
    }
  }
#endif

  //
  // Shutdown...
  //

  Http::Stop();
  Logging::Cleanup();

  delete sc2rcMutex;
  delete th2rcMutex;
  sc2rcMutex = NULL;
  th2rcMutex = NULL;
}
Esempio n. 2
0
  inline string jsonObject(const char *prefix, const char *name, const string &str)
  {
#if REGAL_NO_JSON
    return string();
#else
    //
    // http://www.altdevblogaday.com/2012/08/21/using-chrometracing-to-view-your-inline-profiling-data/
    //
    // object {
    // "cat": "MY_SUBSYSTEM",       // catagory
    // "pid": 4260,                 // process ID
    // "tid": 4776,                 // thread ID
    // "ts": 2168627922668,         // time-stamp of this event
    // "ph": "B",                   // Begin sample
    // "name": "doSomethingCostly", // name of this event
    // "args": { }                  //arguments associated with this event.
    // }
    //

    Json::Output jo;

    jo.object();
    jo.member("cat",prefix);
    jo.member("pid",Thread::procId());
    jo.member("tid",Thread::threadId()%(1<<16));
    jo.member("ts", timer.now());

    // Unnamed logging events such as error, warning and info ones

    if (!name)
    {
      jo.member("ph",  "I");
      jo.member("name",str);
      jo.object("args");
      jo.end();
    }

    // begin/end groupings

    else if (!strcmp(name,"glBegin"))
    {
      jo.member("ph",  "B");
      jo.member("name","glBegin");
      jo.object("args");
        jo.member("inputs",str);
      jo.end();
    }
    else if (!strcmp(name,"glEnd"))
    {
      jo.member("ph",  "E");
      jo.member("name","glBegin");
      jo.object("args");
      jo.end();
    }
    else if (!strcmp(name,"glPushMatrix"))
    {
      jo.member("ph",  "B");
      jo.member("name","glPushMatrix");
      jo.object("args");
        jo.member("inputs",str);
      jo.end();
    }
    else if (!strcmp(name,"glPopMatrix"))
    {
      jo.member("ph",  "E");
      jo.member("name","glPushMatrix");
      jo.object("args");
      jo.end();
    }
    else if (!strcmp(name,"glPushGroupMarkerEXT"))
    {
      jo.member("ph",  "B");
      jo.member("name","glPushGroupMarkerExt");
      jo.object("args");
        jo.member("inputs",str);
      jo.end();
    }
    else if (!strcmp(name,"glPopGroupMarkerEXT"))
    {
      jo.member("ph",  "E");
      jo.member("name","glPushGroupMarkerExt");
      jo.object("args");
      jo.end();
    }

    // Generic named events

    else
    {
      jo.member("ph",  "I");
      jo.member("name",name ? name : "");
      jo.object("args");
        jo.member("inputs",str);
      jo.end();
    }

    jo.end();
    return jo.str();
#endif // REGAL_NO_JSON
  }