import ctypes

from binaryc_python_utils.custom_logging_functions import autogen_C_logging_code, binary_c_log_code, compile_shared_lib


# generate logging lines
logging_line = autogen_C_logging_code(
    {
        'MY_STELLAR_DATA': ['model.time', 'star[0].mass'], 
        'my_sss2': ['model.time', 'star[1].mass']
    }
)

# Generate code around logging lines
created_code = binary_c_log_code(logging_line)

# 
compile_shared_lib(created_code, sourcefile_name='custom_logging.c', outfile_name='libcustom_logging.so')

# Loading library
libmean = ctypes.CDLL("libcustom_logging.so") # loads the shared library

# Get memory adress of function. mimicking a pointer
mem = ctypes.cast(libmean.custom_output_function, ctypes.c_void_p).value