Пример #1
0
static void
s_finalize_proc(lagopus_thread_t *selfptr,
                bool is_canceled, void *arg) {
  lagopus_msg("Called with (%p, %s, %p)\n",
              *selfptr, BOOL_TO_STR(is_canceled), arg);
}
Пример #2
0
static lagopus_result_t
s_main_proc_with_sleep(lagopus_thread_t *selfptr, void *arg) {
  lagopus_msg("Called with (%p, %p)\n", *selfptr, arg);
  sleep(10);
  return LAGOPUS_RESULT_OK;
}
Пример #3
0
static void
s_freeup_proc(lagopus_thread_t *selfptr, void *arg) {
  lagopus_msg("Called with (%p, %p)\n", *selfptr, arg);
}
Пример #4
0
int
main(int argc, const char *const argv[]) {
  const char *nm = myname(argv[0]);
  (void)argc;

  lagopus_log_set_trace_flags(TRACE_OFPT_HELLO |
                              TRACE_OFPT_ERROR |
                              TRACE_OFPT_METER_MOD);

  lagopus_msg("this should emitted to stderr.\n");

  lagopus_msg_trace(TRACE_OFPT_HELLO, false, "hello test.\n");
  lagopus_msg_trace(TRACE_OFPT_ERROR, false, "error test.\n");
  lagopus_msg_trace(TRACE_OFPT_HELLO |
                    TRACE_OFPT_ERROR,
                    false, "hello|error test.\n");

  /*
   * log to stderr.
   */
  if (IS_LAGOPUS_RESULT_OK(
        lagopus_log_initialize(LAGOPUS_LOG_EMIT_TO_UNKNOWN, NULL,
                               false, true, 1)) == false) {
    lagopus_msg_fatal("what's wrong??\n");
    /* not reached. */
  }
  lagopus_dprint("debug to stderr.\n");

  /*
   * log to file.
   */
  if (IS_LAGOPUS_RESULT_OK(
        lagopus_log_initialize(LAGOPUS_LOG_EMIT_TO_FILE, "./testlog.txt",
                               false, true, 10)) == false) {
    lagopus_msg_fatal("what's wrong??\n");
    /* not reached. */
  }
  lagopus_dprint("debug to file.\n");
  lagopus_msg_debug(5, "debug to file, again.\n");
  lagopus_msg_trace(TRACE_OFPT_HELLO, false, "hello file test.\n");
  lagopus_msg_trace(TRACE_OFPT_ERROR, false, "error file test.\n");
  lagopus_msg_trace(TRACE_OFPT_HELLO |
                    TRACE_OFPT_ERROR,
                    false, "hello|error file test.\n");

  if (IS_LAGOPUS_RESULT_OK(
        lagopus_log_initialize(LAGOPUS_LOG_EMIT_TO_SYSLOG, nm,
                               false, false, 10)) == false) {
    lagopus_msg_fatal("what's wrong??\n");
    /* not reached. */
  }
  lagopus_msg_debug(5, "debug to syslog.\n");
  lagopus_msg_trace(TRACE_OFPT_HELLO, false, "hello syslog test.\n");
  lagopus_msg_trace(TRACE_OFPT_ERROR, false, "error syslog test.\n");
  lagopus_msg_trace(TRACE_OFPT_HELLO |
                    TRACE_OFPT_ERROR,
                    false, "hello|error syslog test.\n");

  /*
   * log to stderr, again.
   */
  if (IS_LAGOPUS_RESULT_OK(
        lagopus_log_initialize(LAGOPUS_LOG_EMIT_TO_UNKNOWN, NULL,
                               false, true, 1)) == false) {
    lagopus_msg_fatal("what's wrong??\n");
    /* not reached. */
  }
  lagopus_dprint("will exit 1 ...\n");
  lagopus_exit_error(1, "exit 1 on purpose.\n");

  return 0;
}