Skip to content

Commit

Permalink
Add logger capability to plugins developers (#399)
Browse files Browse the repository at this point in the history
* add set_information_message and set_warning_message

* add documentation

* add doc and update CHANGELOG.rst
  • Loading branch information
alexandrebbruno authored Sep 5, 2024
1 parent 0220420 commit 07b841f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG
===================

* Added support to read historic data curves directly from the results of History Matching analyses.
* Added support for warning and information logging.


2024.1 (2024-05-27)
Expand Down
7 changes: 7 additions & 0 deletions docs/source/plugins/99_1_solver_api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ Liquid-Liquid Mechanistic Model helpers

.. _var_name_parsing:

Solver Logging
~~~~~~~~~~~~~~

.. doxygenfunction:: log_warning_message

.. doxygenfunction:: log_information_message

Variable Name Parsing
~~~~~~~~~~~~~~~~~~~~~

Expand Down
21 changes: 21 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,27 @@ DLL_EXPORT int get_deposition_thickness(
void* ctx, double** out, int phase_id, enum TimestepScope ts_scope, int* size
);

/*!
Logs a warning message at the solver logger.
Information will be logged as follow: "Warning: {warning_message}"
@param[in] ctx ALFAsim's plugins context.
@param[in] plugin_id ALFAsim's plugins id
@param[in] warning_message Warning Message.
@return An #error_code value.
*/
DLL_EXPORT int log_warning_message(void* ctx, const char* plugin_id, const char* warning_message);

/*!
Logs an information message at the solver logger.
@param[in] ctx ALFAsim's plugins context.
@param[in] plugin_id ALFAsim's plugins id
@param[in] info_message Information Message.
@return An #error_code value.
*/
DLL_EXPORT int log_information_message(void* ctx, const char* plugin_id, const char* info_message);

/*!
Retrieves the tracer ID given a tracer reference. A tracer reference may be obtained from the
user input data (See #get_plugin_input_data_reference API function for an example).
Expand Down
5 changes: 5 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ using get_flow_pattern_func = int (*)(
int* size
);
using get_deposition_thickness_func = int (*)(void* ctx, double** out, int phase_id, enum TimestepScope ts_scope, int* size);
using log_warning_message_func = int (*)(void* ctx, const char* plugin_id,const char* warning_message);
using log_information_message_func = int (*)(void* ctx, const char* plugin_id, const char* information_message);
using get_tracer_id_func = int (*)(void* ctx, int* tracer_id, void* reference);
using get_tracer_name_size_func = int (*)(void* ctx, int* tracer_name_size, void* reference);
using get_tracer_name_func = int (*)(void* ctx, char* tracer_name, void* reference, int size);
Expand Down Expand Up @@ -165,6 +167,9 @@ struct ALFAsimSDK_API {

get_deposition_thickness_func get_deposition_thickness;

log_warning_message_func log_warning_message;
log_information_message_func log_information_message;

get_tracer_id_func get_tracer_id;
get_tracer_name_size_func get_tracer_name_size;
get_tracer_name_func get_tracer_name;
Expand Down
2 changes: 2 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api)
api->get_flow_pattern = (get_flow_pattern_func)dlsym(api->handle, "get_flow_pattern");
api->get_liqliq_flow_pattern = (get_flow_pattern_func)dlsym(api->handle, "get_liqliq_flow_pattern");
api->get_deposition_thickness = (get_deposition_thickness_func)dlsym(api->handle, "get_deposition_thickness");
api->log_warning_message = (log_warning_message_func)dlsym(api->handle, "log_warning_message");
api->log_information_message = (log_information_message_func)dlsym(api->handle, "log_information_message");
api->get_plugin_input_data_table_quantity = (get_plugin_input_data_table_quantity_func)dlsym(api->handle, "get_plugin_input_data_table_quantity");
api->get_tracer_id = (get_tracer_id_func)dlsym(api->handle, "get_tracer_id");
api->get_tracer_name_size = (get_tracer_name_size_func)dlsym(api->handle, "get_tracer_name_size");
Expand Down
2 changes: 2 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api)
api->get_flow_pattern = (get_flow_pattern_func)GetProcAddress(api->handle, "get_flow_pattern");
api->get_liqliq_flow_pattern = (get_flow_pattern_func)GetProcAddress(api->handle, "get_liqliq_flow_pattern");
api->get_deposition_thickness = (get_deposition_thickness_func)GetProcAddress(api->handle, "get_deposition_thickness");
api->log_warning_message = (log_warning_message_func)GetProcAddress(api->handle, "log_warning_message");
api->log_information_message = (log_information_message_func)GetProcAddress(api->handle, "log_information_message");
api->get_plugin_input_data_table_quantity = (get_plugin_input_data_table_quantity_func)GetProcAddress(api->handle, "get_plugin_input_data_table_quantity");
api->get_tracer_id = (get_tracer_id_func)GetProcAddress(api->handle, "get_tracer_id");
api->get_tracer_name_size = (get_tracer_name_size_func)GetProcAddress(api->handle, "get_tracer_name_size");
Expand Down

0 comments on commit 07b841f

Please sign in to comment.