liblog/demo/lgdemo.c

102 lines
3.9 KiB
C

/*----------------------------------------------------------------------------*/
/* lgdemo.c */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* This file is part of LibLog. */
/* */
/* LibLog is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* LibLog is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with LibLog. If not, see <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <log.h>
/*----------------------------------------------------------------------------*/
/* Definitions */
/*----------------------------------------------------------------------------*/
#define LGD_MODULE_NAME "dm"
/*----------------------------------------------------------------------------*/
/* Prototypes */
/*----------------------------------------------------------------------------*/
void demo_function( void);
/*----------------------------------------------------------------------------*/
/* Demo_Function */
/*----------------------------------------------------------------------------*/
void Demo_Function( char *Name_Ptr)
{
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Starting [%s]...", Name_Ptr);
LG_STACK_TRACE( LGD_LOG_LEVEL_DEFAULT);
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Completed [%s]!", Name_Ptr);
}
/*----------------------------------------------------------------------------*/
/* main */
/*----------------------------------------------------------------------------*/
int main( int argc, char **argv)
{
LGT_Status status;
if( ( status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
{
fprintf( stderr, "Can't open LibLog library: (%d)\n", status);
return( -1);
}
else
{
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "This is an trace message #: (%d)", 1);
LG_LOG_INFO_1( "This is an info message #: (%d)", 2);
LG_LOG_WARNING_1( "This is an warning message #: (%d)", 3);
LG_LOG_ERROR_1( "This is an error message #: (%d)", 4);
Demo_Function( "Demo_Function");
if( ( status = LG_Library_Close( true)) != LGS_OK)
{
fprintf( stderr, "Can't close LibLog library: (%d)\n", status);
return( -1);
}
}
}