Exemple #1
0
int main(int argc, char *argv[])
{
    log_init(LOG_LEVEL_E, LOG_MODE_PRINT);

    log_v("log level is LOG_LEVEL_E version log\n");
    log_d("log level is LOG_LEVEL_E debug log\n");
    log_e("log level is LOG_LEVEL_E error log\n");

    log_init(LOG_LEVEL_D, LOG_MODE_PRINT);

    log_v("log level is LOG_LEVEL_D version log\n");
    log_d("log level is LOG_LEVEL_D debug log\n");
    log_e("log level is LOG_LEVEL_D error log\n");

    log_init(LOG_LEVEL_V, LOG_MODE_PRINT);

    log_v("log level is LOG_LEVEL_V version log\n");
    log_d("log level is LOG_LEVEL_V debug log\n");
    log_e("log level is LOG_LEVEL_V error log\n");

    log_init(LOG_LEVEL_V, LOG_MODE_FILE);

    log_v("log level is LOG_LEVEL_V version log\n");
    log_d("log level is LOG_LEVEL_V debug log\n");
    log_e("log level is LOG_LEVEL_V error log\n");


    return 0;
}
Exemple #2
0
void log_fatal(const char *path, int line, const char *message, ...)
{
	va_list ap;

	va_start(ap, message);
	log_v(LOG_CRIT, path, line, message, ap);
	va_end(ap);
}
Exemple #3
0
void log_warn(const char *path, int line, const char *message, ...)
{
	va_list ap;

	va_start(ap, message);
	log_v(LOG_WARNING, path, line, message, ap);
	va_end(ap);
}
Exemple #4
0
void log_info(const char *path, int line, const char *message, ...)
{
	va_list ap;

	va_start(ap, message);
	log_v(LOG_DEBUG, path, line, message, ap);
	va_end(ap);
}
Exemple #5
0
/**
 * Elog demo
 */
static void test_elog(void) {
    log_a("Hello EasyLogger!");
    log_e("Hello EasyLogger!");
    log_w("Hello EasyLogger!");
    log_i("Hello EasyLogger!");
    log_d("Hello EasyLogger!");
    log_v("Hello EasyLogger!");
    //elog_raw("Hello EasyLogger!");
}
Exemple #6
0
/**
 * EasyLogger demo
 */
void test_elog(void) {
    /* test log output for all level */
    log_a("Hello EasyLogger!");
    log_e("Hello EasyLogger!");
    log_w("Hello EasyLogger!");
    log_i("Hello EasyLogger!");
    log_d("Hello EasyLogger!");
    log_v("Hello EasyLogger!");
//    elog_raw("Hello EasyLogger!");
}
Exemple #7
0
static void
sax_error_cb (void      * ctx,
	      const char* message,
	      ...)
{
	va_list list;
	va_start (list, message);
	log_v    (ctx, message, list, G_LOG_LEVEL_ERROR);
	va_end   (list);
}
Exemple #8
0
static void
sax_warning_cb (void      * ctx,
		const char* message,
		...)
{
	va_list list;
	va_start (list, message);
	log_v    (ctx, message, list, G_LOG_LEVEL_WARNING);
	va_end   (list);
}
Exemple #9
0
	void on_files_transmitted(const client_file::FilesTransmitted &event)
	{
		log_v(MODULE, "on_files_transmitted(): recipient=%zu", event.recipient);

		replicate::access(m_server, [&](replicate::Interface *ireplicate){
			ireplicate->assign_scene_to_peer(m_main_scene, event.recipient);
		});
		network::access(m_server, [&](network::Interface *inetwork){
			inetwork->send(event.recipient, "core:run_script",
					"buildat.run_script_file(\"main/init.lua\")");
		});
	}
Exemple #10
0
/**
 * Elog demo
 */
static void test_elog(void) {
    /* output all saved log from flash */
    elog_flash_output_all();
    /* test log output for all level */
    log_a("Hello EasyLogger!");
    log_e("Hello EasyLogger!");
    log_w("Hello EasyLogger!");
    log_i("Hello EasyLogger!");
    log_d("Hello EasyLogger!");
    log_v("Hello EasyLogger!");
    elog_raw("Hello EasyLogger!");
    /* trigger assert. Now will run elog_user_assert_hook. All log information will save to flash. */
    ELOG_ASSERT(0);
}
Exemple #11
0
/** Loads configuration string in app_config_buffer. */
static int8_t
_app_config_load_microSD()
{
  int fd;

  // And open it
  fd = cfs_open("inga.cfg", CFS_READ);

  // In case something goes wrong, we cannot save this file
  if (fd == -1) {
    log_e("Failed opening config file\n");
    return -1;
  }


  // do nothing if modification timestamp of file is older/equal than stored
#if CONF_FILE_TIMESTAMP_CHECK
  log_i("Checking config file timestamp...\n");
  if ((cfs_fat_get_last_date(fd) <= system_config._mod_date)
          && (cfs_fat_get_last_time(fd) <= system_config._mod_time)) {
    log_i("Config file is older than stored config, will not be loaded\n");
    cfs_close(fd);
    return -1;
  }
#endif

  // update modification timestamps
  system_config._mod_date = cfs_fat_get_last_date(fd);
  system_config._mod_time = cfs_fat_get_last_time(fd);


  int size = cfs_read(fd, app_config_buffer, MAX_FILE_SIZE);
  app_config_buffer[size] = '\0'; // string null terminator
  log_v("actually read: %d\n", size);
  log_i("Loaded data from microSD card\n");

  cfs_close(fd);

  parse_ini(app_config_buffer, &inga_conf_file);

  app_config_update();

  return 0;
}
Exemple #12
0
	void on_tick(const interface::TickEvent &event)
	{
		log_d(MODULE, "entitytest::on_tick");
		static uint a = 0;
		if(((a++) % 100) == 0){
			main_context::access(m_server, [&](main_context::Interface *imc){
				Scene *scene = imc->check_scene(m_main_scene);
				Node *n = scene->GetChild("Box");
				n->SetPosition(Vector3(0.0f, 6.0f, 0.0f));
				n->SetRotation(Quaternion(30, 60, 90));
				Node *n2 = scene->GetChild("Box2");
				n2->SetPosition(Vector3(-0.4f, 8.0f, 0.0f));
				n2->SetRotation(Quaternion(30, 60, 90));
				m_slow_count++;
				if(m_slow_count == 2){
					Node *n = scene->CreateChild("Box");
					n->SetPosition(Vector3(0.0f, 10.0f, 0.0f));
					n->SetScale(Vector3(1.0f, 1.0f, 1.0f));
					RigidBody *body = n->CreateComponent<RigidBody>();
					CollisionShape *shape = n->CreateComponent<CollisionShape>();
					shape->SetBox(Vector3::ONE);
					body->SetMass(1.0);
					body->SetFriction(0.75f);
					// Model and material is set on client
				}
			});
			return;
		}
		main_context::access(m_server, [&](main_context::Interface *imc){
			Scene *scene = imc->check_scene(m_main_scene);
			Node *n = scene->GetChild("Box");
			//n->Translate(Vector3(0.1f, 0, 0));
			Vector3 p = n->GetPosition();
			log_v(MODULE, "Position: %s", p.ToString().CString());
		});
	}
Exemple #13
0
	void on_client_connected(const network::NewClient &client_connected)
	{
		log_v(MODULE, "entitytest::on_client_connected: id=%zu",
				client_connected.info.id);
	}
Exemple #14
0
int main(int argc, char *argv[])
{
	basic_init();

	client::Config &config = g_client_config;

	const char opts[100] = "hs:P:C:U:l:m:";
	const char usagefmt[1000] =
			"Usage: %s [OPTION]...\n"
			"  -h                   Show this help\n"
			"  -s [address]         Specify server address\n"
			"  -P [share_path]      Specify share/ path\n"
			"  -C [cache_path]      Specify cache/ path\n"
			"  -U [urho3d_path]     Specify Urho3D path\n"
			"  -l [integer]         Set maximum log level (0...5)\n"
			"  -m [name]            Choose menu extension name\n"
	;

	int c;
	while((c = c55_getopt(argc, argv, opts)) != -1)
	{
		switch(c)
		{
		case 'h':
			printf(usagefmt, argv[0]);
			return 1;
		case 's':
			fprintf(stderr, "INFO: config.server_address: %s\n", c55_optarg);
			config.server_address = c55_optarg;
			break;
		case 'P':
			fprintf(stderr, "INFO: config.share_path: %s\n", c55_optarg);
			config.share_path = c55_optarg;
			break;
		case 'C':
			fprintf(stderr, "INFO: config.cache_path: %s\n", c55_optarg);
			config.cache_path = c55_optarg;
			break;
		case 'U':
			fprintf(stderr, "INFO: config.urho3d_path: %s\n", c55_optarg);
			config.urho3d_path = c55_optarg;
			break;
		case 'l':
			log_set_max_level(atoi(c55_optarg));
			break;
		case 'm':
			fprintf(stderr, "INFO: config.menu_extension_name: %s\n", c55_optarg);
			config.menu_extension_name = c55_optarg;
			break;
		default:
			fprintf(stderr, "ERROR: Invalid command-line argument\n");
			fprintf(stderr, usagefmt, argv[0]);
			return 1;
		}
	}

	config.make_paths_absolute();
	if(!config.check_paths()){
		return 1;
	}

	app::Options app_options;

	int exit_status = 0;
	while(exit_status == 0){
		magic::Context context;
		sp_<app::App> app0(app::createApp(&context, app_options));
		sp_<client::State> state(client::createState(app0));
		app0->set_state(state);

		if(config.server_address != ""){
			if(!state->connect(config.server_address, "20000"))
				return 1;
		} else {
			config.boot_to_menu = true;
		}

		exit_status = app0->run();

		if(!app0->reboot_requested())
			break;

		app_options = app0->get_current_options();

		// Re-creating app:App requires guard to be disabled
		buildat_guard_enable(false);
	}
	log_v(MODULE, "Succesful shutdown");
	return exit_status;
}
Exemple #15
0
	void on_client_disconnected(const network::OldClient &old_client)
	{
		log_v(MODULE, "entitytest::on_client_disconnected: id=%zu",
				old_client.info.id);
	}
Exemple #16
0
void
print_config()
{
  log_v("\n\nConfig: \n");
  log_v("_check_sequence:  %d\n", system_config._check_sequence);
  log_v("output.sdcard:    %d\n", system_config.output.sdcard);
  log_v("output.usb:       %d\n", system_config.output.usb);
  log_v("output.radio:     %d\n", system_config.output.radio);
  log_v("output.block_size:%d\n", system_config.output.block_size);
  log_v("battery.enabled:  %d\n", system_config.battery.enabled);
  log_v("battery.rate:     %d\n", system_config.battery.rate);
  log_v("acc.enabled:      %d\n", system_config.acc.enabled);
  log_v("acc.rate:         %d\n", system_config.acc.rate);
  log_v("acc.g_range:      %d\n", system_config.acc.g_range);
  log_v("gyro.enabled:     %d\n", system_config.gyro.enabled);
  log_v("gyro.rate:        %d\n", system_config.gyro.rate);
  log_v("gyro.dps:         %d\n", system_config.gyro.dps);
  log_v("pressure.enabled: %d\n", system_config.pressure.enabled);
  log_v("pressure.rate:    %d\n", system_config.pressure.rate);
  log_v("temp.enabled:     %d\n", system_config.temp.enabled);
  log_v("temp.rate:        %d\n", system_config.temp.rate);
}
Exemple #17
0
	void report_fd(int fd)
	{
		if(fd != m_fd)
			return;
		char buf[INOTIFY_BUFSIZE];
		for(;;){
			int r = read(fd, buf, INOTIFY_BUFSIZE);
			if(r == -1){
				if(errno == EAGAIN)
					break;
				log_w(MODULE, "CFileWatch::report_fd(): read() failed "
						"on fd=%i: %s", fd, strerror(errno));
				break;
			}
			if(r < (int)INOTIFY_STRUCTSIZE){
				throw Exception("CFileWatch::report_fd(): read() -> "+itos(r));
			}
			struct inotify_event *in_event = (struct inotify_event*)buf;
			ss_ name;
			if(r >= (int)INOTIFY_STRUCTSIZE)
				name = &buf[INOTIFY_STRUCTSIZE]; // Null-terminated string
			ss_ mask_s;
			if(in_event->mask & IN_ACCESS) mask_s += "IN_ACCESS | ";
			if(in_event->mask & IN_ATTRIB) mask_s += "IN_ATTRIB | ";
			if(in_event->mask & IN_CLOSE_WRITE) mask_s += "IN_CLOSE_WRITE | ";
			if(in_event->mask & IN_CLOSE_NOWRITE) mask_s += "IN_CLOSE_NOWRITE | ";
			if(in_event->mask & IN_CREATE) mask_s += "IN_CREATE | ";
			if(in_event->mask & IN_DELETE) mask_s += "IN_DELETE | ";
			if(in_event->mask & IN_DELETE_SELF) mask_s += "IN_DELETE_SELF | ";
			if(in_event->mask & IN_MODIFY) mask_s += "IN_MODIFY | ";
			if(in_event->mask & IN_MOVE_SELF) mask_s += "IN_MOVE_SELF | ";
			if(in_event->mask & IN_MOVED_FROM) mask_s += "IN_MOVED_FROM | ";
			if(in_event->mask & IN_MOVED_TO) mask_s += "IN_MOVED_TO | ";
			if(in_event->mask & IN_OPEN) mask_s += "IN_OPEN | ";
			if(in_event->mask & IN_IGNORED) mask_s += "IN_IGNORED | ";
			if(in_event->mask & IN_ISDIR) mask_s += "IN_ISDIR | ";
			if(in_event->mask & IN_Q_OVERFLOW) mask_s += "IN_Q_OVERFLOW | ";
			if(in_event->mask & IN_UNMOUNT) mask_s += "IN_UNMOUNT | ";

			mask_s = mask_s.substr(0, mask_s.size()-3);

			log_d(MODULE, "in_event->wd=%i, mask=%s, name=%s",
					in_event->wd, cs(mask_s), cs(name));

			if(in_event->mask & IN_IGNORED){
				// Inotify removed path from watch
				ss_ path = m_watch_paths[in_event->wd];
				m_watch_paths.erase(in_event->wd);
				int r = inotify_add_watch(m_fd, path.c_str(), IN_CLOSE_WRITE |
						IN_MOVED_TO | IN_CREATE | IN_MOVED_FROM | IN_DELETE |
						IN_MODIFY | IN_ATTRIB);
				if(r == -1){
					log_w(MODULE, "inotify_add_watch() failed: %s (while trying "
							"to re-watch ignored path \"%s\")",
							strerror(errno), cs(path));
				} else {
					log_v(MODULE, "Re-watching auto-ignored path \"%s\" (inotify fd=%i)",
							cs(path), m_fd);
					m_watch_paths[r] = path;
				}
			}
		}
		m_cb();
	}