Home Forums Software Development How to get Tobii's logs?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11562
    tzaccai
    Participant

    hi,
    i’m working with the ET 4C and the Tobii.StreamEngine Nugget (v2.2.2.363).
    on the API Reference that includes in the Nugget (which is from some reason for C++) it says that on tobii_api_create() we can add an additional “custom_log”.
    i tried to search for an example of how to do this, and tried somethings myself – but never reached the “custom_log” method.

    my piece of code:
    —————-

    void custom_logging(IntPtr log_context, tobii_log_level_t level, string text)
    {
    // log messages can be filtered by log level if desired
    Console.WriteLine(“Tobii_Log:: ” + text);
    }

    private bool initEyeTracker()
    {
    tobii_error_t tobiiResult;

    _tobii_log = new tobii_custom_log_t();
    _tobii_log.log_context = new IntPtr();
    _tobii_log.log_func = custom_logging;

    // ——- SETTING API ———-
    tobiiResult = Interop.tobii_api_create(out _tobii_api, _tobii_log);
    if (tobiiResult != tobii_error_t.TOBII_ERROR_NO_ERROR)
    {
    return false;
    }
    ……
    // if all settings (tobii_engine_create, tobii_device_create_ex etc..) finish ok:
    return true
    }

    so my questions are:
    ——————-
    1. does this function works on the Nugget?
    (if the answer is “yes” then:)
    2. how should i work with it & what have i done wrong?
    3. is there any example for this?

    thanks a lot!

    #11576
    Grant [Tobii]
    Keymaster

    Hi @tzaccai, if you checkout the API documentation for tobii.h::tobii_device_create(), taken from tobii_stream_engine_api.pdf as included with the Tobii Stream Engine API download you show see the relevant code implementation.

    void custom_logging( void* log_context, tobii_log_level_t level, char const* text ) {
        // log messages can be filtered by log level if desired
        if( level == TOBII_LOG_LEVEL_ERROR )
            printf( "[%d] %s\n", (int) level, text );
    }
    
    int main() {
        allocation_tracking tracking;
        tracking.total_allocations = 0;
        tracking.current_allocations = 0;
    
        tobii_custom_alloc_t custom_alloc;
        custom_alloc.mem_context = &tracking;
        custom_alloc.malloc_func = &custom_malloc;
        custom_alloc.free_func = &custom_free;
    
        tobii_custom_log_t custom_log;
        custom_log.log_context = NULL; // we don't use the log_context in this example
        custom_log.log_func = &custom_logging;
    
        tobii_api_t* api;
        tobii_error_t error = tobii_api_create( &api, &custom_alloc, &custom_log );
        assert( error == TOBII_ERROR_NO_ERROR );
    
        error = tobii_api_destroy( api );
        assert( error == TOBII_ERROR_NO_ERROR );
    
        printf( "Total allocations: %d\n", tracking.total_allocations );
        printf( "Current allocations: %d\n", tracking.current_allocations );
    
        return 0;
     }

    Hopefully this is exactly what you are looking for! Please do let us know how you get on. Best Wishes.

    #11578
    tzaccai
    Participant

    Hi @Grant, i translated (as far as i could understand) the c++ code from the pdf to c# – and nothing happened.

    i don’t know how to write here the code so it’ll be seen as a piece of code (and not just like one row after another as on my original post)
    but as can be seen there (maybe copy paste it to a text editor?) i’ve implemented both the “custom_logging” method & the “tobii_custom_log_t” variable just as shown on the pdf reference. (but on c#)

    on my log i don’t see any additional logging from this method. not even when initializing the connection with the ET and then getting frequent Gaze Data.

    do you have a c# example?

    #11581
    Grant [Tobii]
    Keymaster

    Hi @tzaccai, you can insert code directly within a forum post using the ‘code’ button along the top of the editor.. alternatively, using a service such as https://codeshare.io or github and we can take a look directly at your C# translation and see where hopefully can be fixed. Thanks.

    I’m afraid we do not have currently a c# example for this particular feature.

    #11618
    tzaccai
    Participant

    my editor’s top is empty, light gray color with no buttons.
    but here is the code snippet:
    https://codeshare.io/G6nQBO

    i understand that you don’t have a c# example.
    but can you help me understand what am missing or doing wrong?
    is this functionality is supported at all?

    thanks

    #11619
    tzaccai
    Participant

    ok. good news.
    apparently i’m receiving msgs from “custom_log” such as:
    licensekey.cpp(503): error “LICENSING_ERROR_OPERATION_FAILED” (00000002) in function “licensekey_parse”

    so i guess i connected well. thanks a lot!

    another small question –
    what is the meaning of the “CONTEXT” variable of the log?
    (custom_log.log_context = NULL; // we don’t use the log_context in this example)

    #11636
    Grant [Tobii]
    Keymaster

    Hi @tzaccai, great! Glad to hear you got things up and runnning and thanks for letting us know.

    With regards to the CONTEXT variable, this will depend of each specific implementation, however you are able to pass a pointer to any specific context (if you should need it in their implementation). If you don’t need any, you may simply pass NULL, as we do in our example, or any random value for that matter.

    Please do let us know if we can provide to you any further information. Best Wishes.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.