diff --git a/demo/lgdemo.c b/demo/lgdemo.c
index a24ae7c..25d38a1 100644
--- a/demo/lgdemo.c
+++ b/demo/lgdemo.c
@@ -3,14 +3,14 @@
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
-/* This file is part of liblog. */
+/* This file is part of LibLog. */
/* */
-/* Drummer is free software: you can redistribute it and/or modify it */
+/* 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. */
/* */
-/* Drummer is distributed in the hope that it will be useful, */
+/* 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. */
@@ -19,6 +19,8 @@
/* along with Drummer. If not, see . */
/*----------------------------------------------------------------------------*/
+
+
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
@@ -75,7 +77,7 @@ int main( int argc, char **argv)
LGT_Status status;
- if( ( status = LG_Library_Open( stderr, LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
+ if( ( status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
{
fprintf( stderr, "Can't open LibLog library: (%d)\n", status);
return( -1);
diff --git a/include/log.h b/include/log.h
index a6fc61a..0bcd5e3 100644
--- a/include/log.h
+++ b/include/log.h
@@ -3,14 +3,14 @@
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
-/* This file is part of liblog. */
+/* This file is part of LibLog. */
/* */
-/* Drummer is free software: you can redistribute it and/or modify it */
+/* LibLog is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
-/* Drummer is distributed in the hope that it will be useful, */
+/* 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 Lesser General Public License for more details. */
@@ -20,6 +20,8 @@
/* . */
/*----------------------------------------------------------------------------*/
+
+
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
@@ -47,14 +49,6 @@
-/*----------------------------------------------------------------------------*/
-/* Global definitions */
-/*----------------------------------------------------------------------------*/
-
-#define LGD_LOG_WRITER_DEFAULT LG_Log_Write
-
-
-
/*----------------------------------------------------------------------------*/
/* Definitions */
/*----------------------------------------------------------------------------*/
@@ -144,23 +138,18 @@ typedef short LGT_Log_Level;
-/*---------------------------------------------------------------------------------*/
-/* LGT_Base */
-/*---------------------------------------------------------------------------------*/
-typedef LGT_Status (*LGT_Log_Writer_Ptr)( LGT_Log_Type_Id, char *, va_list);
+/*----------------------------------------------------------------------------*/
+/* Log Writer */
+/*----------------------------------------------------------------------------*/
-typedef struct LGT_Base
-{
- FILE *Log_Stream_Out_Ptr;
- char *Log_Type_Name_Tab[ LGD_LOG_TYPE_NB];
- LGT_Log_Writer_Ptr Log_Writer_Ptr;
-} LGT_Base;
+typedef LGT_Status (*LGT_Log_Writer_Ptr)( FILE *, LGT_Log_Type_Id, char *, va_list);
+
+#define LGD_LOG_STREAM_DEFAULT ( FILE *)NULL
+#define LGD_LOG_WRITER_DEFAULT ( LGT_Log_Writer_Ptr)NULL
-LGD_API LGT_Base LGG_Base;
-
@@ -172,12 +161,11 @@ LGD_API LGT_Base LGG_Base;
/*----------------------------------------------------------------------------*/
/* LG_Library_Open */
/*----------------------------------------------------------------------------*/
-/* (I) Log_Stream_Out_Ptr: Log output stream */
/* (I) Log_Writer_Ptr: Log writer pointer */
/* (I) Header_Print_Flag: Start by printing an header */
/*----------------------------------------------------------------------------*/
-LGD_API LGT_Status LG_Library_Open( FILE *, LGT_Log_Writer_Ptr, bool);
+LGD_API LGT_Status LG_Library_Open( LGT_Log_Writer_Ptr, bool);
@@ -191,6 +179,26 @@ LGD_API LGT_Status LG_Library_Close( bool);
+/*----------------------------------------------------------------------------*/
+/* LG_Log_Stream_Get */
+/*----------------------------------------------------------------------------*/
+/* (O) Log_Stream_Ptr_Ptr: Log output stream */
+/*----------------------------------------------------------------------------*/
+
+LGD_API LGT_Status LG_Log_Stream_Get( FILE **);
+
+
+
+/*----------------------------------------------------------------------------*/
+/* LG_Log_Stream_Set */
+/*----------------------------------------------------------------------------*/
+/* (I) Log_Stream_Ptr: Log output stream */
+/*----------------------------------------------------------------------------*/
+
+LGD_API LGT_Status LG_Log_Stream_Set( FILE *);
+
+
+
/*----------------------------------------------------------------------------*/
/* LG_Log */
/*----------------------------------------------------------------------------*/
@@ -199,14 +207,6 @@ LGD_API LGT_Status LG_Log( LGT_Log_Type_Id, LGT_Log_Level, char *, char *, lo
-/*----------------------------------------------------------------------------*/
-/* LG_Log_Write */
-/*----------------------------------------------------------------------------*/
-
-LGD_API LGT_Status LG_Log_Write( LGT_Log_Type_Id, char *, va_list);
-
-
-
/*------------------------------------------------------------------------------*/
/* LG_Stack_Trace_Print */
/*------------------------------------------------------------------------------*/
diff --git a/lib/liblog.c b/lib/liblog.c
index 3dce229..72b5d12 100644
--- a/lib/liblog.c
+++ b/lib/liblog.c
@@ -3,14 +3,14 @@
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
-/* This file is part of liblog. */
+/* This file is part of LibLog. */
/* */
-/* Drummer is free software: you can redistribute it and/or modify it */
+/* LibLog is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
-/* Drummer is distributed in the hope that it will be useful, */
+/* 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 Lesser General Public License for more details. */
@@ -20,14 +20,14 @@
/* . */
/*----------------------------------------------------------------------------*/
+
+
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#define _LIBLOG_C_
-
-
#include
@@ -38,9 +38,8 @@
/* LG_Library_Open */
/*----------------------------------------------------------------------------*/
-LGT_Status LG_Library_Open( FILE *Log_Stream_Out_Ptr, LGT_Log_Writer_Ptr Log_Writer_Ptr, bool Header_Print_Flag)
+LGT_Status LG_Library_Open( LGT_Log_Writer_Ptr Log_Writer_Ptr, bool Header_Print_Flag)
{
- LGG_Base.Log_Stream_Out_Ptr = Log_Stream_Out_Ptr;
LGG_Base.Log_Writer_Ptr = Log_Writer_Ptr;
if( Header_Print_Flag) LG_Log_Header( LGD_LOG_LEVEL_DEFAULT);
@@ -67,27 +66,63 @@ LGT_Status LG_Library_Close( bool Footer_Print_Flag)
+/*----------------------------------------------------------------------------*/
+/* LG_Log_Stream_Out_Get */
+/*----------------------------------------------------------------------------*/
+/* (O) Log_Stream_Out_Ptr_Ptr: Log output stream */
+/*----------------------------------------------------------------------------*/
+
+LGT_Status LG_Log_Stream_Out_Get( FILE **Log_Stream_Out_Ptr_Ptr)
+{
+ *Log_Stream_Out_Ptr_Ptr = LGG_Base.Log_Stream_Out_Ptr;
+
+ return( LGS_OK);
+}
+
+
+
+
+
+/*----------------------------------------------------------------------------*/
+/* LG_Log_Stream_Out_Set */
+/*----------------------------------------------------------------------------*/
+/* (I) Log_Stream_Out_Ptr: Log output stream */
+/*----------------------------------------------------------------------------*/
+
+LGT_Status LG_Log_Stream_Out_Set( FILE *Log_Stream_Out_Ptr)
+{
+ LGG_Base.Log_Stream_Out_Ptr = Log_Stream_Out_Ptr;
+
+ return( LGS_OK);
+}
+
+
+
+
+
/*----------------------------------------------------------------------------*/
/* LG_Log_Header */
/*----------------------------------------------------------------------------*/
LGT_Status LG_Log_Header( LGT_Log_Type_Id Log_Type_Id, ...)
{
- va_list args;
- char fmt[255];
- LGT_Log_Writer_Ptr log_writer_ptr;
- LGT_Status status;
+ va_list args;
+ char fmt[255];
+ FILE *log_stream_out_ptr;
+ LGT_Log_Writer_Ptr log_writer_ptr;
+ LGT_Status status;
- log_writer_ptr = ( ( LGG_Base.Log_Writer_Ptr == NULL) ? &LG_Log_Write : LGG_Base.Log_Writer_Ptr);
+ log_stream_out_ptr = ( ( LGG_Base.Log_Stream_Out_Ptr == NULL) ? LGD_LOG_STREAM_DEFAULT_VALUE : LGG_Base.Log_Stream_Out_Ptr);
+ log_writer_ptr = ( ( LGG_Base.Log_Writer_Ptr == NULL) ? LGD_LOG_WRITER_DEFAULT_VALUE : LGG_Base.Log_Writer_Ptr);
va_start( args, Log_Type_Id);
sprintf( fmt, "\nYY/MM/DD|hh:mm:ss.uuuu|Typ|Lev|Name| File Name |Line| Log Message\n");
- status = ( *log_writer_ptr)( Log_Type_Id, fmt, args);
+ status = ( *log_writer_ptr)( log_stream_out_ptr, Log_Type_Id, fmt, args);
sprintf( fmt, "--------+-------------+---+---+----+---------------------+----+-------------------------------------------------------------------\n");
- status = ( *log_writer_ptr)( Log_Type_Id, fmt, args);
+ status = ( *log_writer_ptr)( log_stream_out_ptr, Log_Type_Id, fmt, args);
va_end( args);
@@ -104,18 +139,20 @@ LGT_Status LG_Log_Header( LGT_Log_Type_Id Log_Type_Id, ...)
LGT_Status LG_Log_Footer( LGT_Log_Type_Id Log_Type_Id, ...)
{
- va_list args;
- char fmt[255];
- LGT_Log_Writer_Ptr log_writer_ptr;
- LGT_Status status;
+ va_list args;
+ char fmt[255];
+ FILE *log_stream_out_ptr;
+ LGT_Log_Writer_Ptr log_writer_ptr;
+ LGT_Status status;
- log_writer_ptr = ( ( LGG_Base.Log_Writer_Ptr == NULL) ? &LG_Log_Write : LGG_Base.Log_Writer_Ptr);
+ log_stream_out_ptr = ( ( LGG_Base.Log_Stream_Out_Ptr == NULL) ? LGD_LOG_STREAM_DEFAULT_VALUE : LGG_Base.Log_Stream_Out_Ptr);
+ log_writer_ptr = ( ( LGG_Base.Log_Writer_Ptr == NULL) ? LGD_LOG_WRITER_DEFAULT_VALUE : LGG_Base.Log_Writer_Ptr);
va_start( args, Log_Type_Id);
sprintf( fmt, "--------+-------------+---+---+----+---------------------+----+-------------------------------------------------------------------\n");
- status = ( *log_writer_ptr)( Log_Type_Id, fmt, args);
+ status = ( *log_writer_ptr)( log_stream_out_ptr, Log_Type_Id, fmt, args);
va_end( args);
@@ -132,13 +169,14 @@ LGT_Status LG_Log_Footer( LGT_Log_Type_Id Log_Type_Id, ...)
LGT_Status LG_Log( LGT_Log_Type_Id Log_Type_Id, LGT_Log_Level Log_Level, char *Module_Name, char *File_Name, long Line_Id, bool LF_Flag, char *Log_Fmt, ...)
{
- va_list args;
- char fmt[255];
- int rc;
- LGT_Log_Writer_Ptr log_writer_ptr;
- LGT_Status status;
-
+ va_list args;
+ char fmt[255];
+ int rc;
+ FILE *log_stream_out_ptr;
+ LGT_Log_Writer_Ptr log_writer_ptr;
+ LGT_Status status;
+
if( LG_Log_Format( fmt, Log_Type_Id, Log_Level, Module_Name, File_Name, Line_Id, LF_Flag, Log_Fmt) != LGS_OK)
{
fprintf( stderr, "LG_Log: Can't format log messages (%d)!!!\n", errno);
@@ -147,9 +185,10 @@ LGT_Status LG_Log( LGT_Log_Type_Id Log_Type_Id, LGT_Log_Level Log_Level, char
va_start( args, Log_Fmt);
- log_writer_ptr = ( ( LGG_Base.Log_Writer_Ptr == NULL) ? &LG_Log_Write : LGG_Base.Log_Writer_Ptr);
+ log_stream_out_ptr = ( ( LGG_Base.Log_Stream_Out_Ptr == NULL) ? LGD_LOG_STREAM_DEFAULT_VALUE : LGG_Base.Log_Stream_Out_Ptr);
+ log_writer_ptr = ( ( LGG_Base.Log_Writer_Ptr == NULL) ? LGD_LOG_WRITER_DEFAULT_VALUE : LGG_Base.Log_Writer_Ptr);
- status = ( *log_writer_ptr)( Log_Type_Id, fmt, args);
+ status = ( *log_writer_ptr)( log_stream_out_ptr, Log_Type_Id, fmt, args);
va_end( args);
@@ -175,7 +214,7 @@ LGT_Status LG_Log_Format( char *Out_Fmt, LGT_Log_Type_Id Log_Type_Id, LGT_Log
if( ( tm_ptr = localtime( &( cur_timeval.tv_sec))) == NULL)
{
fprintf( LGG_Base.Log_Stream_Out_Ptr, "LG_Log: %s: can't convert localtime (%d) !\n", __FILE__, errno);
-
+
return( LGS_KO);
}
@@ -196,12 +235,12 @@ LGT_Status LG_Log_Format( char *Out_Fmt, LGT_Log_Type_Id Log_Type_Id, LGT_Log
/* LG_Log_Write */
/*----------------------------------------------------------------------------*/
-LGT_Status LG_Log_Write( LGT_Log_Type_Id Log_Type_Id, char *Out_Fmt_Ptr, va_list Args)
+LGT_Status LG_Log_Write( FILE *Log_Stream_Out_Ptr, LGT_Log_Type_Id Log_Type_Id, char *Out_Fmt_Ptr, va_list Args)
{
int rc;
- rc = vfprintf( LGG_Base.Log_Stream_Out_Ptr, Out_Fmt_Ptr, Args);
+ rc = vfprintf( Log_Stream_Out_Ptr, Out_Fmt_Ptr, Args);
if( rc < 0)
{
diff --git a/lib/liblog.h b/lib/liblog.h
index 04cbcf1..a806f43 100644
--- a/lib/liblog.h
+++ b/lib/liblog.h
@@ -3,14 +3,14 @@
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
-/* This file is part of liblog. */
+/* This file is part of LibLog. */
/* */
-/* Drummer is free software: you can redistribute it and/or modify it */
+/* LibLog is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
-/* Drummer is distributed in the hope that it will be useful, */
+/* 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 Lesser General Public License for more details. */
@@ -20,6 +20,8 @@
/* . */
/*----------------------------------------------------------------------------*/
+
+
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
@@ -45,20 +47,35 @@
/* Definitions */
/*----------------------------------------------------------------------------*/
-#define LGD_LOG_WRITER_DEFAULT LG_Log_Write
-
#define LGD_MODULE_NAME "lg"
-/*----------------------------------------------------------------------------*/
-/* LGT_Base */
-/*----------------------------------------------------------------------------*/
+
+
+/*---------------------------------------------------------------------------------*/
+/* LGT_Base */
+/*---------------------------------------------------------------------------------*/
+
+typedef struct LGT_Base
+{
+ FILE *Log_Stream_Out_Ptr;
+ char *Log_Type_Name_Tab[ LGD_LOG_TYPE_NB];
+ LGT_Log_Writer_Ptr Log_Writer_Ptr;
+} LGT_Base;
+
+
+
+#define LGD_LOG_STREAM_DEFAULT_VALUE ( FILE *)stderr
+#define LGD_LOG_WRITER_DEFAULT_VALUE ( LGT_Log_Writer_Ptr)&LG_Log_Write
+
+
LGT_Base LGG_Base =
{
- NULL,
- { LGD_LOG_TYPE_NAME_UNKNOWN, LGD_LOG_TYPE_NAME_TRACE, LGD_LOG_TYPE_NAME_INFO, LGD_LOG_TYPE_NAME_WARNING, LGD_LOG_TYPE_NAME_ERROR}
+ LGD_LOG_STREAM_DEFAULT,
+ { LGD_LOG_TYPE_NAME_UNKNOWN, LGD_LOG_TYPE_NAME_TRACE, LGD_LOG_TYPE_NAME_INFO, LGD_LOG_TYPE_NAME_WARNING, LGD_LOG_TYPE_NAME_ERROR},
+ LGD_LOG_WRITER_DEFAULT
};
@@ -93,6 +110,14 @@ LGT_Status LG_Log_Format( char *, LGT_Log_Type_Id, LGT_Log_Level, char *, cha
+/*----------------------------------------------------------------------------*/
+/* LG_Log_Write */
+/*----------------------------------------------------------------------------*/
+
+LGT_Status LG_Log_Write( FILE *Log_Stream_Out_Ptr, LGT_Log_Type_Id, char *, va_list);
+
+
+