Skip to content

Commit

Permalink
[memory][refactor] Restruct logs
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaZotov committed Oct 21, 2023
1 parent 05bf6c1 commit feefc67
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,8 @@ sc_dictionary_fs_memory_status sc_dictionary_fs_memory_save(sc_dictionary_fs_mem
if (status != SC_FS_MEMORY_OK)
return status;

sc_message("\tLast string offset: %lld", memory->last_string_offset);

sc_fs_memory_info("All sc-fs-memory dictionaries saved");
return status;
}
Expand Down
14 changes: 13 additions & 1 deletion sc-memory/sc-core/sc-store/sc-fs-memory/sc_fs_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,15 @@ sc_bool _sc_fs_memory_load_sc_memory_segments(sc_storage * storage)

sc_io_channel_shutdown(segments_channel, SC_FALSE, null_ptr);

sc_message("\tLoaded segments count: %d", storage->segments_count);
sc_message("\tLast not engaged segment num: %d", storage->last_not_engaged_segment_num);
sc_message("\tLast released segment num: %d", storage->last_released_segment_num);

if (is_no_deprecated_segments)
sc_fs_memory_info("Sc-memory segments loaded");
else
sc_fs_memory_warning("Deprecated sc-memory segments loaded");

sc_message("\tSc-memory segments: %u", storage->segments_count);
return SC_TRUE;

error:
Expand All @@ -264,8 +267,13 @@ sc_bool _sc_fs_memory_load_sc_memory_segments(sc_storage * storage)

sc_bool sc_fs_memory_load(sc_storage * storage)
{
sc_monitor_acquire_write(&storage->segments_monitor);

sc_bool const sc_memory_result = _sc_fs_memory_load_sc_memory_segments(storage);
sc_bool const sc_fs_memory_result = manager->load(manager->fs_memory) == SC_FS_MEMORY_OK;

sc_monitor_release_write(&storage->segments_monitor);

return sc_memory_result && sc_fs_memory_result;
}

Expand Down Expand Up @@ -376,6 +384,10 @@ sc_bool _sc_fs_memory_save_sc_memory_segments(sc_storage * storage)
}
}

sc_message("\tLoaded segments count: %d", storage->segments_count);
sc_message("\tLast not engaged segment num: %d", storage->last_not_engaged_segment_num);
sc_message("\tLast released segment num: %d", storage->last_released_segment_num);

sc_mem_free(tmp_filename);
sc_io_channel_shutdown(segments_channel, SC_TRUE, null_ptr);
sc_fs_memory_info("Sc-memory segments saved");
Expand Down
13 changes: 9 additions & 4 deletions sc-memory/sc-core/sc-store/sc_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ sc_bool sc_storage_initialize(sc_memory_params const * params)
sc_monitor_init(&storage->segments_monitor);
_sc_monitor_global_init(&storage->addr_monitors_table);

sc_memory_info("Configuration:");
sc_message("\tSc-element size: %zd", sizeof(sc_element));
sc_message("\tSc-storage size: %zd", sizeof(sc_storage));
sc_message("\tMax segments count: %d", storage->max_segments_count);
sc_message("\tMax threads count: %d", params->max_threads);
sc_message("\tSave period: %d", params->save_period);
sc_message("\tUpdate period: %d", params->update_period);
sc_message("\tClean on initialize: %s", params->clear ? "On" : "Off");

sc_result result = SC_TRUE;
if (params->clear == SC_FALSE)
{
sc_monitor_acquire_write(&storage->segments_monitor);
result = sc_fs_memory_load(storage);
sc_monitor_release_write(&storage->segments_monitor);
}

storage->event_queue = sc_events_initialize_ext(params->max_events_and_agents_threads);

Expand Down
36 changes: 15 additions & 21 deletions sc-memory/sc-core/sc_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,25 @@ sc_mutex s_concurrency_mutex;

sc_memory_context * sc_memory_initialize(const sc_memory_params * params)
{
sc_memory_info("Initialize components");
sc_memory_info("Initialize");

sc_char * string = sc_version_string_new(&params->version);
sc_memory_info("Version: %s", string);
sc_version_string_free(string);

sc_message("\tClean on initialize: %s", params->clear ? "On" : "Off");
sc_message("\tExtensions path: %s", params->ext_path);
sc_message("\tSave period: %d", params->save_period);
sc_message("\tUpdate period: %d", params->update_period);

sc_memory_info("Logger:");
sc_message("\tLog type: %s", params->log_type);
sc_message("\tLog file: %s", params->log_file);
sc_message("\tLog level: %s", params->log_level);

sc_memory_info("Configuration:");
sc_message("\tMax loaded segments: %d", params->max_loaded_segments);
sc_message("\tMax threads: %d", params->max_threads);
sc_message("\tSc-element size: %zd", sizeof(sc_element));

sc_memory_info("Build configuration:");
sc_message("\tResult structure upload: %s", params->init_memory_generated_upload ? "On" : "Off");
sc_message("\tInit memory generated structure: %s", params->init_memory_generated_structure);

if (sc_storage_initialize(params) == SC_FALSE)
{
sc_memory_error("Error while initialize sc-storage");
goto error;
}

sc_storage_start_new_process();

s_context_hash_table = g_hash_table_new(g_direct_hash, g_direct_equal);
s_memory_default_ctx = sc_memory_context_new(sc_access_lvl_make(SC_ACCESS_LVL_MAX_VALUE, SC_ACCESS_LVL_MAX_VALUE));

Expand All @@ -73,6 +61,11 @@ sc_memory_context * sc_memory_initialize(const sc_memory_params * params)
}
sc_memory_context_free(helper_ctx);

sc_memory_info("Build configuration:");
sc_message("\tResult structure upload: %s", params->init_memory_generated_upload ? "On" : "Off");
sc_message("\tInit memory generated structure: %s", params->init_memory_generated_structure);
sc_message("\tExtensions path: %s", params->ext_path);

sc_addr init_memory_generated_structure = SC_ADDR_EMPTY;
if (params->init_memory_generated_upload)
sc_helper_resolve_system_identifier(
Expand All @@ -84,15 +77,17 @@ sc_memory_context * sc_memory_initialize(const sc_memory_params * params)
goto error;
}

sc_memory_info("All components successfully initialized");
sc_memory_info("Initialized");
sc_storage_end_new_process();

sc_memory_info("Successfully initialized");
return s_memory_default_ctx;

error:
{
sc_storage_end_new_process();

sc_memory_context_free(s_memory_default_ctx);
sc_memory_info("Components initialized with errors");
sc_memory_info("No initialized");
sc_memory_info("Initialized with errors");
return null_ptr;
}
}
Expand Down Expand Up @@ -126,7 +121,7 @@ sc_result sc_memory_init_ext(

void sc_memory_shutdown(sc_bool save_state)
{
sc_memory_info("Shutdown components");
sc_memory_info("Shutdown");

sc_memory_shutdown_ext();
sc_helper_shutdown();
Expand All @@ -140,7 +135,6 @@ void sc_memory_shutdown(sc_bool save_state)
s_context_hash_table = null_ptr;
s_context_id_last = 0;

sc_memory_info("All components shutdown");
sc_memory_info("Shutdown");
}

Expand Down

0 comments on commit feefc67

Please sign in to comment.