/* {{{ axis2_environment create function */ axutil_env_t * wsf_env_create_svr ( axis2_char_t * path_tolog, int loglevel) { axutil_allocator_t *allocator = NULL; axutil_error_t *error = NULL; axutil_log_t *log = NULL; axis2_char_t log_path[1024]; axutil_env_t *env = NULL; axutil_thread_pool_t *thread_pool = NULL; const axis2_char_t *LOG_NAME = "wsf_ruby_server.log"; allocator = malloc (sizeof (axutil_allocator_t)); allocator->free_fn = wsf_free_wrapper; allocator->malloc_fn = wsf_malloc_wrapper; allocator->realloc = wsf_realloc_warpper; error = axutil_error_create (allocator); if (path_tolog && ( (0 == strcmp (path_tolog, "")) || (0 == strcmp (path_tolog, ".")) || (0 == strcmp (path_tolog, "./")))) { snprintf (log_path, sizeof(log_path), "%s", LOG_NAME); } else { snprintf (log_path, sizeof(log_path), "%s/%s", path_tolog, LOG_NAME); } thread_pool = axutil_thread_pool_init (allocator); log = axutil_log_create (allocator, NULL, log_path); env = axutil_env_create_with_error_log_thread_pool (allocator, error, log, thread_pool); env->log->level = loglevel; return env; }
/***************************** End of function headers ************************/ axutil_env_t * init_syetem_env( axutil_allocator_t * allocator, const axis2_char_t * log_file) { axutil_error_t *error = axutil_error_create(allocator); axutil_log_t *log = axutil_log_create(allocator, NULL, log_file); axutil_thread_pool_t *thread_pool = axutil_thread_pool_init(allocator); /* We need to init the parser in main thread before spawning child * threads */ axiom_xml_reader_init(); return axutil_env_create_with_error_log_thread_pool(allocator, error, log, thread_pool); }
AXIS2_EXTERN axutil_env_t *AXIS2_CALL axutil_env_create_all( const axis2_char_t *log_file, const axutil_log_levels_t log_level) { axutil_env_t *env = NULL; axutil_error_t *error = NULL; axutil_log_t *log = NULL; axutil_allocator_t *allocator = NULL; axutil_thread_pool_t *thread_pool = NULL; allocator = axutil_allocator_init(NULL); error = axutil_error_create(allocator); if(log_file) { log = axutil_log_create(allocator, NULL, log_file); } /* if log file name was not given or the log could not be create with given name, create default log */ if(!log) { log = axutil_log_create_default(allocator); } thread_pool = axutil_thread_pool_init(allocator); env = axutil_env_create_with_error_log_thread_pool(allocator, error, log, thread_pool); if(env->log) { /*if(AXIS2_LOG_LEVEL_CRITICAL <= log_level && log_level <= AXIS2_LOG_LEVEL_TRACE)*/ if (log_level <= AXIS2_LOG_LEVEL_TRACE) { env->log->level = log_level; } else { env->log->level = AXIS2_LOG_LEVEL_DEBUG; /* default log level is debug */ } } env->ref = 1; env->get_session_fn = NULL; env->set_session_fn = NULL; return env; }
void test_log_write( ) { char msg[20]; printf("start of test_log_write\n\n"); axutil_allocator_t *allocator = axutil_allocator_init(NULL); if (!allocator) { printf("allocator is NULL\n"); return; } axutil_error_t *error = axutil_error_create(allocator); if (!error) { printf("cannot create error\n"); return; } axutil_log_t *log22 = axutil_log_create(allocator, NULL, NULL); if (!log22) { printf("cannot create log\n"); return; } log22->level = AXIS2_LOG_LEVEL_DEBUG; const axutil_env_t *env = axutil_env_create_with_error_log(allocator, error, log22); if (!env) { printf("cannot create env with error and log\n"); return; } strcpy(msg, "abcd test123"); AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, "log1 %s", "test1"); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "log2 %d", 2); AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "log3 %s", "test3"); AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "log4 %s %s", "info1", "info2"); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "log5 %s %d", "test", 5); printf("end of test_log_write \n\n"); }
void test_axutil_dir_handler_list_service_or_module_dirs( ) { int i, isize; axutil_file_t *file = NULL; axis2_char_t *filename = NULL; axutil_allocator_t *allocator = axutil_allocator_init(NULL); axutil_error_t *error = axutil_error_create(allocator); axutil_log_t *log = axutil_log_create(allocator, NULL, NULL); const axutil_env_t *env = axutil_env_create_with_error_log(allocator, error, log); axis2_char_t *pathname = axutil_strdup(env, "/tmp/test/"); axutil_array_list_t *arr_folders = axutil_dir_handler_list_service_or_module_dirs(env, pathname); if (arr_folders == NULL) { printf("List of folders is NULL\n"); return; } isize = axutil_array_list_size(arr_folders, env); printf("Folder array size = %d \n", isize); for (i = 0; i < isize; ++i) { file = (axutil_file_t *) axutil_array_list_get(arr_folders, env, i); filename = axutil_file_get_name(file, env); printf("filename = %s \n", filename); } printf ("----end of test_axutil_dir_handler_list_service_or_module_dirs----\n"); }