Beispiel #1
0
int main_initialize( void )
{
    int ret = 0;

    application_t application = {0};
    application.name = "bin2hex";
    application.short_name = "bin2hex";
    application.config_dir = "bin2hex";
    application.flags = APPLICATION_UTILITY;

    log_enable_prefix( false );

    if( ( ret = foundation_initialize( memory_system_malloc(), application ) ) < 0 )
        return ret;

    config_set_int( HASH_FOUNDATION, HASH_TEMPORARY_MEMORY, 32 * 1024 );

    return 0;
}
Beispiel #2
0
int
main_initialize(void) {
	int ret = 0;
	application_t application;
	foundation_config_t foundation_config;
	resource_config_t resource_config;
	window_config_t window_config;
	render_config_t render_config;

	memset(&foundation_config, 0, sizeof(foundation_config));
	memset(&resource_config, 0, sizeof(resource_config));
	memset(&window_config, 0, sizeof(window_config));
	memset(&render_config, 0, sizeof(render_config));

	memset(&application, 0, sizeof(application));
	application.name = string_const(STRING_CONST("rendercompile"));
	application.short_name = string_const(STRING_CONST("rendercompile"));
	application.config_dir = string_const(STRING_CONST("rendercompile"));
	application.flags = APPLICATION_UTILITY;

	log_enable_prefix(false);
	log_set_suppress(0, ERRORLEVEL_WARNING);

	resource_config.enable_local_source = true;
	resource_config.enable_local_cache = true;
	resource_config.enable_remote_cache = true;

	if ((ret = foundation_initialize(memory_system_malloc(), application, foundation_config)) < 0)
		return ret;
	if ((ret = resource_module_initialize(resource_config)) < 0)
		return ret;
	if ((ret = window_module_initialize(window_config)) < 0)
		return ret;
	if ((ret = render_module_initialize(render_config)) < 0)
		return ret;

	log_set_suppress(HASH_RESOURCE, ERRORLEVEL_DEBUG);
	log_set_suppress(HASH_RENDER, ERRORLEVEL_INFO);

	return 0;
}
Beispiel #3
0
int main_initialize(void) {
	int ret = 0;

	application_t application;
	memset(&application, 0, sizeof(application));
	application.name = string_const(STRING_CONST("Vector mask generator"));
	application.short_name = string_const(STRING_CONST("maskgen"));
	application.company = string_const(STRING_CONST("Rampant Pixels"));
	application.version = vector_module_version();
	application.flags = APPLICATION_UTILITY;

	log_enable_prefix(false);

	foundation_config_t config;
	memset(&config, 0, sizeof(config));

	if ((ret = foundation_initialize(memory_system_malloc(), application, config)) < 0)
		return ret;

	return 0;
}
Beispiel #4
0
int
main_initialize(void) {
	int ret = 0;
	application_t application;
	foundation_config_t config;

	memset(&config, 0, sizeof(config));

	memset(&application, 0, sizeof(application));
	application.name = string_const(STRING_CONST("hashify"));
	application.short_name = string_const(STRING_CONST("hashify"));
	application.flags = APPLICATION_UTILITY;

	log_enable_prefix(false);
	log_set_suppress(0, ERRORLEVEL_ERROR);

	if ((ret = foundation_initialize(memory_system_malloc(), application, config)) < 0)
		return ret;

	return 0;
}
Beispiel #5
0
DECLARE_TEST(error, output) {
#if BUILD_ENABLE_LOG
	error_handler_fn handler_error = error_handler();
	log_handler_fn handler_log = log_handler();
	string_const_t shortmsg = string_const(STRING_CONST("Short message with prefix"));
    string_const_t longmsg = string_const(STRING_CONST("Longer message which should be output without a prefix"));

	error_set_handler(ignore_error_handler);
	log_set_handler(log_verify_handler);

    log_enable_stdout(false);
    EXPECT_EQ(log_stdout(), false);
    log_warn(HASH_TEST, WARNING_SUSPICIOUS, STRING_ARGS(shortmsg));
    log_enable_stdout(true);
    EXPECT_EQ(log_stdout(), true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_WARNING);
	EXPECT_GE(_last_log_length, shortmsg.length);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), 0);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("WARNING [suspicious]"), 0), STRING_NPOS);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_stdout(false);
	log_warn(HASH_TEST, (warning_t)0x1000, STRING_ARGS(shortmsg));
    log_enable_stdout(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_WARNING);
	EXPECT_GE(_last_log_length, shortmsg.length);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), 0);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("WARNING [4096]"), 0), STRING_NPOS);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_prefix(false);
    log_enable_stdout(false);
	log_warn(HASH_TEST, WARNING_SYSTEM_CALL_FAIL, STRING_ARGS(longmsg));
    log_enable_stdout(true);
    log_enable_prefix(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_WARNING);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(longmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(longmsg), 0), 0);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_stdout(false);
	log_error(HASH_TEST, ERROR_DEPRECATED, STRING_ARGS(shortmsg));
    log_enable_stdout(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_ERROR);
	EXPECT_GE(_last_log_length, shortmsg.length);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), 0);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("ERROR [deprecated]"), 0), STRING_NPOS);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_stdout(false);
	log_error(HASH_TEST, (error_t)0x1000, STRING_ARGS(shortmsg));
    log_enable_stdout(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_ERROR);
	EXPECT_GE(_last_log_length, shortmsg.length);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), 0);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("ERROR [4096]"), 0), STRING_NPOS);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

	log_enable_prefix(false);
    log_enable_stdout(false);
	log_error(HASH_TEST, ERROR_INVALID_VALUE, STRING_ARGS(longmsg));
    log_enable_stdout(true);
    log_enable_prefix(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_ERROR);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(longmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(longmsg), 0), 0);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_stdout(false);
	log_panic(HASH_TEST, ERROR_DEPRECATED, STRING_ARGS(shortmsg));
    log_enable_stdout(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_PANIC);
	EXPECT_GE(_last_log_length, shortmsg.length);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), 0);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("PANIC [deprecated]"), 0), STRING_NPOS);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_stdout(false);
	log_panic(HASH_TEST, (error_t)0x1000, STRING_ARGS(shortmsg));
    log_enable_stdout(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_PANIC);
	EXPECT_GE(_last_log_length, shortmsg.length);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(shortmsg), 0), 0);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("PANIC [4096]"), 0), STRING_NPOS);

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

	log_enable_prefix(false);
    log_enable_stdout(false);
	log_panic(HASH_TEST, ERROR_INVALID_VALUE, STRING_ARGS(longmsg));
    log_enable_stdout(true);
    log_enable_prefix(true);
	EXPECT_EQ(_last_log_context, HASH_TEST);
	EXPECT_EQ(_last_log_severity, ERRORLEVEL_PANIC);
	EXPECT_NE(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(longmsg), 0), STRING_NPOS);
	EXPECT_GT(string_find_string(_last_log_msg, _last_log_length, STRING_ARGS(longmsg), 0), 0);

#  if BUILD_ENABLE_ERROR_CONTEXT
    
	error_context_push(STRING_CONST("one"), STRING_CONST("dataone"));
	error_context_push(STRING_CONST("two"), STRING_CONST("datatwo"));
	error_context_push(STRING_CONST("three"), STRING_CONST("datathree"));

	_last_log_context = 0;
	_last_log_severity = ERRORLEVEL_NONE;
	_last_log_msg = nullptr;
	_last_log_length = 0;

    log_enable_stdout(false);
	log_error_context(HASH_TEST, ERRORLEVEL_INFO);
    log_enable_stdout(true);

    error_context_pop();
    error_context_pop();
    error_context_pop();

	EXPECT_SIZEEQ(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("When one: dataone"), 0), STRING_NPOS);
	EXPECT_SIZEEQ(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("When two: datatwo"), 0), STRING_NPOS);
	EXPECT_SIZENE(string_find_string(_last_log_msg, _last_log_length, STRING_CONST("When three: datathree"), 0), STRING_NPOS);

#  endif

	log_set_handler(handler_log);
	error_set_handler(handler_error);
#endif
	return 0;
}