Home › Forums › Software Development › How to get Tobii's logs?
Tagged: custom_logging, log, log_func, tobii_api_create
- This topic has 6 replies, 2 voices, and was last updated 5 years, 3 months ago by Grant [Tobii].
- AuthorPosts
- 30/06/2019 at 17:22 #11562tzaccaiParticipant
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!
03/07/2019 at 22:26 #11576Grant [Tobii]KeymasterHi @tzaccai, if you checkout the API documentation for
tobii.h::tobii_device_create()
, taken fromtobii_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.
04/07/2019 at 15:05 #11578tzaccaiParticipantHi @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?
04/07/2019 at 17:38 #11581Grant [Tobii]KeymasterHi @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.
07/07/2019 at 10:37 #11618tzaccaiParticipantmy editor’s top is empty, light gray color with no buttons.
but here is the code snippet:
https://codeshare.io/G6nQBOi 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
07/07/2019 at 16:26 #11619tzaccaiParticipantok. 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)09/07/2019 at 13:21 #11636Grant [Tobii]KeymasterHi @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.
- AuthorPosts
- You must be logged in to reply to this topic.