Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - SLOG2 Buffer Size QNX7: (7 Items)
   
SLOG2 Buffer Size QNX7  
Hi, is there a way to know the current size (not the capacity or max size, but how much has been used) of the buffer in 
an slog2 handle? 

Following some of the examples in the site, it's possible to extract each individual log by

- Calling slog2_open_log(...)
- Calling slog2_get_log_info(...)
- Then you can get buffer_info

But there's only max capacity, and no current size of the buffer exposed. There's a size member in the structure, but it
 only represents the size of the buffer_info struct itself, and not the size of the buffer.

Thanks in advance!
Re: SLOG2 Buffer Size QNX7  
Those are ringbuffers so I'm not sure what sense it would make to know that?

They will always be full except at startup.
Re: SLOG2 Buffer Size QNX7  
If you wanted to implement some sort of ping pong buffer so that you could save slog2 to disk, you'd have to know when 
the front buffer was getting close to being full, then swap buffers so that logging can continue, and now you could save
 the back buffer, and so on (since saving to disk is a blocking operation and could take a while).
Re: SLOG2 Buffer Size QNX7  
For that you are better off using something like.

/**
 * callback function that writes each log line to the file
 * @param info      populated slog2_packet_info_t struct
 * @param payload   data
 * @param param     this must be a callback_param_t pointer
 */

int my_callback( slog2_packet_info_t *info, void *payload, void *callback_param )
{
   printf("time:%"PRIx64" severity:%u code:%u fname:%s bname:%s pid:%i tid:%i msg:%s\n", info->timestamp, info->severity
, info->code, info->file_name, info->buffer_name, info->owner_pid, info->thread_id, (char*)payload);
   return 0;
}





    slog2_packet_info_t packet_info = SLOG2_PACKET_INFO_INIT;

    slog2_parse_all( SLOG2_PARSE_FLAGS_DYNAMIC,
                                NULL,
                                NULL,
                                &packet_info,
                                my_callback,
                                NULL );


http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.lib_ref/topic/s/slog2_parse_all.html


or just redirect the slog2info output to a file.
Re: SLOG2 Buffer Size QNX7  
Thanks for the reply. Hmm, this is interesting. So PARSE_DYNAMIC is intended for extracting logs that are being actively
 written by slog2 by other processes? You would get a callback after every new log?
Thanks
Re: SLOG2 Buffer Size QNX7  
It's the same as starting slog2info with the .-w arg.

If you are only interested in certain buffers you can allso pass in a list similar to the slog2info -b argument.
Re: SLOG2 Buffer Size QNX7  
Hey John, wanted to take a chance to thank you for your input. Your suggestions helped me solve my problem. I ended up 
using slog2_parse_all(DYNAMIC). I realized this after the fact, but calling this function does not return (unless you 
return a non-zero value from your user-defined callback), and the user-defined callback gets called from within whatever
 thread context you execute it, where you can process each new log entry. This works well for me, I can just throw new 
logs into my own local ring buffer and defer disk writes (log persistence) with another thread (which has read-access to
 the rb).