示例#1
0
static void
s_once_proc(void) {
  char *dbg_lvl_str = getenv("LAGOPUS_LOG_DEBUGLEVEL");
  char *logfile = getenv("LAGOPUS_LOG_FILE");
  uint16_t d = 0;
  lagopus_log_destination_t log_dst = LAGOPUS_LOG_EMIT_TO_UNKNOWN;

  if (IS_VALID_STRING(dbg_lvl_str) == true) {
    uint16_t tmp = 0;
    if (lagopus_str_parse_uint16(dbg_lvl_str, &tmp) == LAGOPUS_RESULT_OK) {
      d = tmp;
    }
  }
  if ((logfile = s_validate_path(logfile, s_is_valid_path)) != NULL) {
    log_dst = LAGOPUS_LOG_EMIT_TO_FILE;
  }

  if (lagopus_log_initialize(log_dst, logfile, false, true, d) !=
      LAGOPUS_RESULT_OK) {
    lagopus_exit_error(1, "logger initialization error.\n");
  }

  if (d > 0) {
    lagopus_msg_debug(d, "Logger debug level is set to: %d.\n", d);
  }

#ifdef HAVE_PROCFS_SELF_EXE
  if (readlink("/proc/self/exe", s_exefile, PATH_MAX) != -1) {
    (void)lagopus_set_command_name(s_exefile);
    lagopus_msg_debug(10, "set the command name '%s'.\n",
                      lagopus_get_command_name());
  }
#endif /* HAVE_PROCFS_SELF_EXE */
}
示例#2
0
static void
s_once_proc(void) {
  char *dbg_lvl_str = getenv("LAGOPUS_LOG_DEBUGLEVEL");
  char *logfile = getenv("LAGOPUS_LOG_FILE");
  uint16_t d = 0;
  lagopus_log_destination_t log_dst = LAGOPUS_LOG_EMIT_TO_UNKNOWN;

  if (IS_VALID_STRING(dbg_lvl_str) == true) {
    uint16_t tmp = 0;
    if (lagopus_str_parse_uint16(dbg_lvl_str, &tmp) == LAGOPUS_RESULT_OK) {
      d = tmp;
    }
  }
  if ((logfile = s_validate_path(logfile, s_is_valid_path)) != NULL) {
    log_dst = LAGOPUS_LOG_EMIT_TO_FILE;
  }

  if (lagopus_log_initialize(log_dst, logfile, false, true, d) !=
      LAGOPUS_RESULT_OK) {
    lagopus_exit_error(1, "logger initialization error.\n");
  }

  if (d > 0) {
    lagopus_msg_debug(d, "Logger debug level is set to: %d.\n", d);
  }
}
示例#3
0
static void
s_once_proc(void) {
  char *dbg_lvl_str = getenv("MCCP_LOG_DEBUGLEVEL");
  char *logfile = getenv("MCCP_LOG_FILE");
  uint64_t d = 0;
  mccp_log_destination_t log_dst = MCCP_LOG_EMIT_TO_UNKNOWN;

  if (IS_VALID_STRING(dbg_lvl_str) == true) {
    uint64_t tmp = 0;
    if (mccp_str_parse_uint64(dbg_lvl_str, &tmp) == MCCP_RESULT_OK) {
      d = tmp;
    }
  }
  if ((logfile = s_validate_path(logfile, s_is_valid_path)) != NULL) {
    log_dst = MCCP_LOG_EMIT_TO_FILE;
  }

  if (mccp_log_initialize(log_dst, logfile, false, true, d, 0LL) !=
      MCCP_RESULT_OK) {
    mccp_exit_error(1, "logger initialization error.\n");
  }

  if (d > 0) {
    mccp_msg_debug(d, "Logger debug level is set to: " PF64(u) ".\n", d);
  }
}