1#include <config.h>
2#include "log.h"
3
4/*!
5 * \brief Clear all log messages.
6 *
7 * \param hLog
8 *
9 * \return int
10 * \retval LOG_ERROR
11 * \retval LOG_SUCCESS
12 *
13 * \sa logOpen
14 * logClose
15 */
16int logClear( HLOG hLog )
17{
18 /* we have to be logOpen to logClear messages */
19 if ( !hLog ) return LOG_ERROR;
20
21 /* We rely upon a callback being set to handle clearing mem used by each msg.
22 This should be set in logOpen but just in case - we check it here. */
23 if ( !hLog->hMessages->pFree ) return LOG_ERROR;
24
25 /* go to last message and delete until no more messages */
26 lstLast( hLog->hMessages );
27 while ( !lstEOL( hLog->hMessages ) )
28 {
29 lstDelete( hLog->hMessages );
30 }
31
32 return LOG_SUCCESS;
33}
34
35
36