Beispiel #1
0
int main(int argc, char *argv[])
{
    sd_test_t *t;
    int ret;
    FILE *f;

    t = sd_test_new(argc, argv);
    log4c_init();

    appender = log4c_appender_get("stream");
    f = fopen("/dev/null", "w+");
    log4c_appender_set_udata(appender, f);

    root = log4c_category_get("root");
    log4c_category_set_appender(root, appender);
    log4c_category_set_priority(root, LOG4C_PRIORITY_TRACE);

    sd_test_add(t, test_big);

    ret = sd_test_run(t, argc, argv);

    log4c_appender_set_udata(appender, NULL);
    fclose(f);

    sd_test_delete(t);

    log4c_fini();
    return ! ret;
}
Beispiel #2
0
extern log4c_appender_t* log4c_appender_get(const char* a_name)
{
  static const sd_factory_ops_t log4c_appender_factory_ops = {
    (void*) log4c_appender_new,
    (void*) log4c_appender_delete,
    (void*) log4c_appender_print,
  };
  
  if (!log4c_appender_factory) {
    log4c_appender_factory = sd_factory_new("log4c_appender_factory", 
      &log4c_appender_factory_ops);
    
    /* build default appenders */
    log4c_appender_set_udata(log4c_appender_get("stderr"), stderr);
    log4c_appender_set_udata(log4c_appender_get("stdout"), stdout);
  }
  
  return sd_factory_get(log4c_appender_factory, a_name);
}