Esempio n. 1
0
void LogStream::set_stream(TextOutput out) {
  // temporarily disable writes, otherwise at log level MEMORY the log is
  // displayed using the old out_ object, which is in the process of being
  // freed (generally this leads to a segfault)
  LogLevel old = get_log_level();
  set_log_level(SILENT);
  out_ = out;
  set_log_level(old);
}
Esempio n. 2
0
static void edit_control(struct v4l2_camera *cam)
{
    struct v4l2_control ctrl;
    int cur_level = get_log_level();
    int c;
    set_log_level(DEBUG);
    camera_query_support_control(cam);
    scanf("%d%x%d", &c, &ctrl.id, &ctrl.value);
    if (c == 1)
        camera_set_control(cam, &ctrl);
    else
        camera_get_control(cam, &ctrl);
    LOGI("%d\n", ctrl.value);
    set_log_level(cur_level);
}
Esempio n. 3
0
int main(int argc, char **argv) {

    int debug = 0;
    int cgb_mode = 1;
    //char file_name[1024] = "sdmc:/rom.gb";
    
    char file_name[1024];
    if (!selectFile(&cgb_mode, file_name)) {
        cleanup();
        return 0;
    };

    ClientOrServer cs = NO_CONNECT;
   
    set_log_level(LOG_INFO);

    if (!init_emu(file_name, debug, !cgb_mode, cs)) {
        log_message(LOG_ERROR, "Failed to initialize emulator\n");
        cleanup();
        return 1;
    }
    
    log_message(LOG_INFO, "Running emu\n");
    run();

    write_SRAM();
    cleanup();
	return 0;
}
Esempio n. 4
0
void test_learner() {
  
  set_log_level(NONE);
  init_store();

  _node_count = 4;
  recv_from = &recv_from_scenario; 
  send_to = &send_to_scenario;
  sendidx = recvidx = 0;
  recv = learner_basic_recv;
  send = learner_basic_send;
  intheory_sm(LEARNER);

  sendidx = recvidx = 0;
  recv = learner_getfail_recv;
  send = learner_getfail_send;
  intheory_sm(LEARNER);

  sendidx = recvidx = 0;
  recv = learner_expand_recv;
  send = learner_expand_send;
  intheory_sm(LEARNER);

  sendidx = recvidx = 0;
  recv = learner_mixed_recv;
  send = learner_mixed_send;
  intheory_sm(LEARNER);

}
Esempio n. 5
0
/* SET LOG */
static void
quote_log( struct Client *source_p, int newval )
{
  const char *log_level_as_string;

  if (newval >= 0)
  {
    if (newval < L_WARN)
    {
      sendto_one(source_p, ":%s NOTICE %s :LOG must be > %d (L_WARN)",
                 me.name, source_p->name, L_WARN);
      return;
    }

    if (newval > L_DEBUG)
    {
      newval = L_DEBUG;
    }

    set_log_level(newval);
    log_level_as_string = get_log_level_as_string(newval);
    sendto_realops_flags(UMODE_ALL, L_ALL,"%s has changed LOG level to %i (%s)",
                         source_p->name, newval, log_level_as_string);
  }
  else
  {
    sendto_one(source_p, ":%s NOTICE %s :LOG level is currently %i (%s)",
               me.name, source_p->name, get_log_level(),
               get_log_level_as_string(get_log_level()));
  }
}
Esempio n. 6
0
void
init_dtls(session_t *dst) {
  PRINTF("DTLS client started\n");

  print_local_addresses();

  dst->size = sizeof(dst->addr) + sizeof(dst->port);
  dst->port = UIP_HTONS(20220);

  set_connection_address(&dst->addr);
  client_conn = udp_new(&dst->addr, 0, NULL);
  udp_bind(client_conn, dst->port);

  PRINTF("set connection address to ");
  PRINT6ADDR(&dst->addr);
  PRINTF(":%d\n", uip_ntohs(dst->port));

  set_log_level(LOG_DEBUG);

  dtls_context = dtls_new_context(client_conn);
  if (dtls_context) {
    dtls_set_psk(dtls_context, (unsigned char *)"secretPSK", 9,
		 (unsigned char *)"Client_identity", 15);
		 
    dtls_set_cb(dtls_context, read_from_peer, read);
    dtls_set_cb(dtls_context, send_to_peer, write);
  }
}
Esempio n. 7
0
int main(int argc, char **argv) {
	set_log_level(Logger::LEVEL_MIN);
	if (argc != 2) {
		usage(argc, argv);
		return EXIT_FAILURE;
	}
	char *input_folder = argv[1];
	if (!file_exists(input_folder)) {
		printf("input_folder[%s] not exists!\n", input_folder);
		return EXIT_FAILURE;
	}
	leveldb::DB *db;
	leveldb::Options options;
	auto status = leveldb::DB::Open(options, input_folder, &db);
	if (!status.ok()) {
		printf("open leveldb: %s error!\n", input_folder);
		return EXIT_FAILURE;
	}
  char space[sizeof(TMsg)];
	auto read_opts = leveldb::ReadOptions();
  read_opts.fill_cache = false;
	leveldb::Iterator *it = db->NewIterator(read_opts);
	for (it->SeekToFirst(); it->Valid(); it->Next()) {
    TMsg *msg = TMsg::TryParse(it, space);
    if (msg) {
      std::cout << *msg << std::endl;
      msg->~TMsg();
    }
	}
	delete db;
	return EXIT_SUCCESS;
}
Esempio n. 8
0
void
init_dtls(session_t *dst) {
  static dtls_handler_t cb = {
    .write = send_to_peer,
    .read  = read_from_peer,
    .event = NULL,
    .get_key = get_key
  };
  PRINTF("DTLS client started\n");

  print_local_addresses();

  dst->size = sizeof(dst->addr) + sizeof(dst->port);
  dst->port = UIP_HTONS(20220);

  set_connection_address(&dst->addr);
  client_conn = udp_new(&dst->addr, 0, NULL);
  udp_bind(client_conn, dst->port);

  PRINTF("set connection address to ");
  PRINT6ADDR(&dst->addr);
  PRINTF(":%d\n", uip_ntohs(dst->port));

  set_log_level(LOG_DEBUG);

  dtls_context = dtls_new_context(client_conn);
  if (dtls_context)
    dtls_set_handler(dtls_context, &cb);
}
Esempio n. 9
0
File: test_log.c Progetto: hytd/sos
s32 test_log_all(u32 argc, char **argv)
{
    s32 ret = 0;
    u32 i, arg1;
    i    = atoi(argv[2]);
    arg1 = atoi(argv[3]);
    switch(i) {
        case (0):
            arg1 = arg1 > LOG_MAX ? LOG_MAX : arg1;
            PRINT_EMG("set loglevel [%s]\n", loglevel_desc[arg1]);
            ret = set_log_level(arg1);
            break;
        case (1):
            log(LOG_EMG,   "%d: %s\n", __LINE__, "hello, world!");
            log(LOG_ERR, "%d: %s\n", __LINE__, "hello, world!");
            log(LOG_WARN,  "%d: %s\n", __LINE__, "hello, world!");
            log(LOG_INFO,  "%d: %s\n", __LINE__, "hello, world!");
            log(LOG_DEBUG, "%d: %s\n", __LINE__, "hello, world!");
            break;
        default:
            return -1;
    }

    return ret;
}
Esempio n. 10
0
int main(int argc, char **args) {
  if (argc < 5) {
    printf("Usage: %s LOCAL_ADDRESS:LOCAL_PORT second_node:port third_node:port fourth_node:port ...\n", args[0]);
    printf("   ex: %s 10.0.0.1:4321 10.0.0.2:4321 10.0.0.3:4321 10.0.0.4:4321 ...\n", args[0]);
    return 1;
  }

  set_log_level(GRAPH);
  char * all_nodes[argc - 1];

  all_nodes[0] = args[1];
  int i = 1;
  for (; i < argc; i++) {
    all_nodes[i] = args[i + 1];
  }


  start_intheory(0, argc - 1, all_nodes);

  register_changed_cb(SLOT, got_hello);
  printf("MY ID: %d\n", my_id());
  if (my_id() == 0) {
    printf("I guess I'm the designated hello-er! Start your nodes!\n");
    sleep(5);
    say_hello();
  }

  while (hellos_received < 1) { sleep(1); }

  stop_intheory();
  return 0;
}
Esempio n. 11
0
void
Logger::incr_log_level(LogLevel level)
{
  if (get_log_level() < level)
  {
    set_log_level(level);
  }
}
Esempio n. 12
0
int main()
{
        printf("%cwhat\n", 0x20);
    	set_log_level(5);
	    log_info("what");
    	sleep(1);
	    return 0;
}
Esempio n. 13
0
void SetLogState::set(LogLevel l) {
  reset();
  if (l != DEFAULT) {
    level_ = get_log_level();
    set_log_level(l);
  } else {
    level_ = DEFAULT;
  }
}
Esempio n. 14
0
/** Uses getopt() to parse the command line and set configuration values
 */
void parse_commandline(int argc, char **argv) {
  int c;
  int i;

  s_config *config = config_get_config();

  while (-1 != (c = getopt(argc, argv, "c:hfd:sw:vi:"))) {

    switch(c) {

    case 'h':
      usage();
      exit(1);
      break;

    case 'c':
      if (optarg) {
	strncpy(config->configfile, optarg, sizeof(config->configfile));
      }
      break;

    case 'w':
      if (optarg) {
	free(config->ndsctl_sock);
	config->ndsctl_sock = safe_strdup(optarg);
      }
      break;

    case 'f':
      config->daemon = 0;
      break;

    case 'd':
      if (optarg) {
	set_log_level(atoi(optarg));
      }
      break;

    case 's':
      config->log_syslog = 1;
      break;

    case 'v':
      printf("This is nodogsplash version " VERSION "\n");
      exit(1);
      break;

    default:
      usage();
      exit(1);
      break;

    }

  }

}
Esempio n. 15
0
int TraceLog::get_log_level()
{
    if (!got_env_)
    {
        const char *log_level_str = getenv(LOG_LEVEL_ENV_KEY);
        set_log_level(log_level_str);
    }
    return log_level_;
}
Esempio n. 16
0
/*************************************************************************
**************************************************************************
   procargs - Process command line arguments.  Exit on error by calling
              usage().

   Input:
      argc - number of arguments
      argv - array of argument strings
   Output:
      tbd
**************************************************************************/
static void procargs(int argc, char **argv, char** cfg_files,
		     const int cfg_files_max, int *cfg_count)
{
   int opt;
   const char *const option_spec = "b:c:hl:";
   int cfg_i = 1;

   if ((argc == 2) && strcmp(argv[1], "-version") == 0) {
      getVersion();
      exit(EXIT_SUCCESS);
   }

   while ((opt = getopt(argc, argv, option_spec)) != -1) {
      switch(opt) {
      case 'b':			/* override default config file */
	 if (1 != cfg_i) {
	    fprintf(stderr, "Override the default configuration first, "
		    "before adding to it.\n");
	 }
	 cfg_files[0] = optarg;
	 break;

     case 'c':			/* additional config file */
	 if (cfg_i == cfg_files_max) {
	    fprintf(stderr, "Too many configuration files, max=%d.\n", 
		    cfg_files_max);
	    exit(EXIT_FAILURE);
	 }
	 cfg_files[cfg_i++] = optarg;
	 break;

      case 'h':
	 usage(argv[0]);
	 break;

      case 'l':
	 if (set_log_level(optarg) < 0) {
	    exit(EXIT_FAILURE);
	 }
	 break;

       case '?':
	 usage(argv[0]);
	 break;

      default:
	 fprintf(stderr, "Programming error: "
		 "incompletely implemented option: '%c'.\n", opt);
	 exit(EXIT_FAILURE);
      }
   }
   if (optind == argc) {
      usage(argv[0]);
   }
   *cfg_count = cfg_i;
}
Esempio n. 17
0
int main(int argc, char **argv)
{
	// TODO: 根据配置文件,启动相应的策略.
	set_log_level(4);

	Policy policy;
	policy.find_policy();

	return 0;
}
Esempio n. 18
0
void SetLogState::do_reset() {
  if (level_ != DEFAULT) {
    if (obj_) {
      obj_->set_log_level(level_);
    } else {
      set_log_level(level_);
    }
    obj_ = nullptr;
    level_ = DEFAULT;
  }
}
Esempio n. 19
0
bool skeleton_init(const char* appname, int loglvl, int maxfdcnt)
{
	set_rlimit();
	set_signal();
	init_log(appname);
	set_log_level(loglvl);
	toggle_hex_level();
	init_timer();

	return gevloop.init(maxfdcnt);
}
Esempio n. 20
0
static void init_log_level(void)
{
	int debug_level = get_console_loglevel();

	if (CONSOLE_LEVEL_CONST)
		return;

	get_option(&debug_level, "debug_level");

	set_log_level(debug_level);
}
Esempio n. 21
0
int main()
{
	log_init();
	set_log_name("log.txt");
	set_log_level(LOG_LEVEL_INFO);
	log_write(LOG_LEVEL_INFO, "info");
	log_write(LOG_LEVEL_WARN, "warning");
	log_write(LOG_LEVEL_ERRO, "error");

	return 0;
}
Esempio n. 22
0
        void register_loggers() {
            auto sinks = create_sinks();

            for (auto &logger_name : loggers_to_initialize) {
                auto logger = std::make_shared<spdlog::logger>(logger_name, sinks.begin(), sinks.end());
                spdlog::register_logger(logger);
            }

            auto log_level = Agent::getArgs()->getArgValue(AgentArgs::ARG_LOG_LEVEL);
            set_log_level(log_level);
            log(LOGGER_AGENT)->info("Log level successfully set to: {}.", log_level);
        }
Esempio n. 23
0
int insertProperty(const char *key, void* value)
{
#ifdef SDFAPIONLY
    /* SDFSetPropery may be called before loadProperties, initialize the hash here in this case */
    if (!_sdf_globalPropertiesMap) {
        initializeProperties();
    }
#endif
    if (strcmp(key, "ZS_LOG_LEVEL") == 0)
        set_log_level(value);
    return ((SDF_TRUE == HashMap_put(_sdf_globalPropertiesMap, key, value)) ? 0 : 1);
}
Esempio n. 24
0
static void
set_log_level_from_environment_variable() {
  const char *string = getenv( "LOG_LEVEL" );
  if ( string == NULL ) {
    return;
  }

  for ( int i = 0; i <= ( LOG_DEBUG - LOG_CRIT ); i++ ) {
    if ( strncasecmp( string, log_levels[ i ], strlen( log_levels[ i ] ) ) == 0 ) {
      set_log_level( i + LOG_CRIT );
    }
  }
}
Esempio n. 25
0
void usage(int rc)
{
	struct mod_action mod;
	FILE *fp = rc ? stderr : stdout;

	version(fp);
	fprintf(fp, "Copyright (C) 2000-2008, Parallels, Inc.\n");
	fprintf(fp, "This program may be distributed under the terms of the GNU GPL License.\n\n");
	fprintf(fp, "Usage: vzctl [options] <command> <veid> [parameters]\n"
"vzctl destroy | mount | umount | stop | restart | status | enter <veid>\n"
"vzctl create <veid> [--ostemplate <name>] [--config <name>]\n"
"   [--private <path>] [--root <path>] [--ipadd <addr>] | [--hostname <name>]\n"
"vzctl start <veid> [--force] [--wait]\n"
"vzctl exec | exec2 <veid> <command> [arg ...]\n"
"vzctl runscript <veid> <script>\n"
"vzctl chkpnt <veid> [--dumpfile <name>]\n"
"vzctl restore <veid> [--dumpfile <name>]\n"
"vzctl set <veid> [--save] [--setmode restart|ignore]\n"
"   [--ipadd <addr>] [--ipdel <addr>|all] [--hostname <name>]\n"
"   [--nameserver <addr>] [--searchdomain <name>] [--onboot yes|no]\n"
"   [--userpasswd <user>:<passwd>] [--cpuunits <N>] [--cpulimit <N>] [--cpus <N>]\n"
"   [--diskspace <soft>[:<hard>]] [--diskinodes <soft>[:<hard>]]\n"
"   [--quotatime <N>] [--quotaugidlimit <N>]\n"
"   [--noatime yes|no] [--capability <name>:on|off ...]\n"
"   [--devices b|c:major:minor|all:r|w|rw]\n"
"   [--devnodes device:r|w|rw|none]\n"
"   [--netif_add <ifname[,mac,host_ifname,host_mac]]>] [--netif_del <ifname>]\n"
"   [--applyconfig <name>] [--applyconfig_map <name>]\n"
"   [--features <name:on|off>] [--name <vename>]\n"
"   [--ioprio <N>]\n");


	fprintf(fp, "   [--iptables <name>] [--disabled <yes|no>]\n");
	fprintf(fp, "   [UBC parameters]\n"
"UBC parameters (N - items, P - pages, B - bytes):\n"
"Two numbers divided by colon means barrier:limit.\n"
"In case the limit is not given it is set to the same value as the barrier.\n"
"   --numproc N[:N]	--numtcpsock N[:N]	--numothersock N[:N]\n"
"   --vmguarpages P[:P]	--kmemsize B[:B]	--tcpsndbuf B[:B]\n"
"   --tcprcvbuf B[:B]	--othersockbuf B[:B]	--dgramrcvbuf B[:B]\n"
"   --oomguarpages P[:P]	--lockedpages P[:P]	--privvmpages P[:P]\n"
"   --shmpages P[:P]	--numfile N[:N]		--numflock N[:N]\n"
"   --numpty N[:N]	--numsiginfo N[:N]	--dcachesize N[:N]\n"
"   --numiptent N[:N]	--physpages P[:P]	--avnumproc N[:N]\n");
	memset(&mod, 0, sizeof(mod));
	set_log_level(0);
	init_modules(&mod, NULL);
	mod_print_usage(&mod);
	free_modules(&mod);
	exit(rc);
}
Esempio n. 26
0
int main(int argc, char* argv[]) 
{
  polymec_init(argc, argv);
  set_log_level(LOG_DEBUG);
  const struct CMUnitTest tests[] = 
  {
    cmocka_unit_test(test_exodus_file_query),
    cmocka_unit_test(test_write_exodus_file),
    cmocka_unit_test(test_read_exodus_file),
    cmocka_unit_test(test_read_poly_exodus_file),
    cmocka_unit_test(test_write_poly_exodus_file)
  };
  return cmocka_run_group_tests(tests, NULL, NULL);
}
Esempio n. 27
0
static PyObject *log_level(PyObject *self, PyObject *args)
{
    enum gpi_log_levels new_level;
    PyObject *py_level;
    PyObject *value;

    py_level = PyTuple_GetItem(args, 0);
    new_level = (enum gpi_log_levels)PyLong_AsLong(py_level);

    set_log_level(new_level);

    value = Py_BuildValue("s", "OK!");

    return value;
}
Esempio n. 28
0
int main(int argc, char **argv)
{
    int i, start_option, test_mode;

    if (argc < 2) {
        printf("mq_test [-d log_level] [-c|-s] [-q]\n");
        printf("-c      Client mode\n");
        printf("-s      Server mode\n");
        printf("-h      Host\n");
        printf("**NOTE:  Defaults to launching both client and server for internal testing\n");
        return(0);
    }

    i = 1;

    do {
        start_option = i;

        if (strcmp(argv[i], "-d") == 0) { //** Enable debugging
            i++;
            set_log_level(atol(argv[i]));
            i++;
        } else if (strcmp(argv[i], "-c") == 0) { //** Client mode
            i++;
            test_mode = MODE_CLIENT;
        } else if (strcmp(argv[i], "-s") == 0) { //** Server mode
            i++;
            test_mode = MODE_SERVER;
        } else if (strcmp(argv[i], "-s") == 0) { //** Server mode
            i++;
            host = argv[i];
            i++;
        }
    } while ((start_option < i) && (i<argc));


    apr_wrapper_start();
    init_opque_system();
    init_random();

    if (test_mode == MODE_CLIENT) {
        run_client();
    } else {
        run_server();
    }

    return(0);
}
Esempio n. 29
0
TEST(RequestTest, test_parse_post) {
    set_log_level("WARN");

    Request req;
    int ret = req.parse_request(TEST_POST_REQ.c_str(), TEST_POST_REQ.size());
    if (ret != 0) {
        LOG_ERROR("PARSE request error which ret:%d, req str:%s", ret, TEST_POST_REQ.c_str());
    }
    ASSERT_EQ(0, ret);
    std::string name = req.get_param("name");
    std::string pwd = req.get_param("pwd");
    LOG_INFO("Get 'name' param :%s", name.c_str());
    LOG_INFO("Get 'pwd' param :%s", pwd.c_str());
    ASSERT_STREQ("aa", name.c_str());
    ASSERT_STREQ("xx", pwd.c_str());
}
Esempio n. 30
0
static void 
parse_options(int argc, char **argv)
{
  int c;
  
  while ((c = getopt(argc, argv, "u:hd")) != -1) {
    switch (c) {
    case 'h':
      usage();
      exit(EXIT_OK);
    case 'd':
      set_log_level(LOG_LEVEL_DBG);
      break;
    case 'u':
      username = optarg;
      break;
    default:
      usage();
      exit(EXIT_CLIOPT_ERR);
    }
  }

  /* get server hostname */
  if (optind < argc) {
    server = argv[optind];
    ldbg ("Parsed server host name as %s", server);
    optind++;
  } else
  {
    fprintf(stderr, "ERROR: IVPN server hostname required\n\n");
    usage();
    exit(EXIT_CLIOPT_ERR);
  }
  
  /* get the optional port number */
  if (optind < argc) {
    port = atoi(argv[optind]);
    ldbg ("Parsed server port as %u", port);
    optind++;
  }
  
  if (optind < argc) {
    fprintf(stderr, "ERROR: Extra arguments in command line\n\n");
    usage();
    exit(EXIT_CLIOPT_ERR);
  }
}