Commit 5c227203 authored by Tristan Leteurtre's avatar Tristan Leteurtre

. Added a log ability to the syslog deamon

    (Compile with ./configure --enable-syslog (default enable))
    Should compile under Windows (--disable-syslog).

  . Added the logging method selection in vls.cfg :
    BEGIN "Vls"
      LogFile       = "vls.log"             # log file
      ScreenLog     = "enable"              # log to the console
      SystemLog     = "disable"             # log to the systemlog
    END
parent 5a5f6c55
......@@ -47,6 +47,7 @@ PLUGINS = @PLUGINS@
#
DEBUG=@DEBUG@
PROFILING=@PROFILING@
SYSLOG=@SYSLOG@
#BUILD=BASE_RELEASE
#BUILD=OPTIM_RELASE
......@@ -119,6 +120,14 @@ ifeq ($(PROFILING), 1)
CCFLAGS+=-pg
endif
#
# System Logging
#
ifeq ($(SYSLOG), 1)
CCFLAGS+=-DSYSLOG
endif
#
# Standard release mode
#
......
......@@ -841,6 +841,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-debug Disable debug mode (default enabled)
--enable-profiling Enable profiling mode (default disabled)
--disable-syslog Logging using syslogd (default enable)
--disable-dvd DVD support (default enabled)
--enable-dvb DVB support (default disabled)
......@@ -6267,6 +6268,143 @@ if test "${enable_profiling+set}" = set; then
if test x$enableval = xyes; then PROFILING=1; fi
fi;
for ac_header in syslog.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
egrep -v '^ *\+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
no:yes )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
SYSLOG=1
else
SYSLOG=0
fi
done
# Check whether --enable-syslog or --disable-syslog was given.
if test "${enable_syslog+set}" = set; then
enableval="$enable_syslog"
if test x$enableval = xno
then
SYSLOG=0
fi
fi;
if test x$enable_syslog = xyes
then
if test ${SYSLOG} = 0
then
{ { echo "$as_me:$LINENO: error: Could not find syslog.h. You can alternately configure
using --disable-syslog" >&5
echo "$as_me: error: Could not find syslog.h. You can alternately configure
using --disable-syslog" >&2;}
{ (exit 1); exit 1; }; }
fi
fi
# Check whether --enable-dvd or --disable-dvd was given.
if test "${enable_dvd+set}" = set; then
enableval="$enable_dvd"
......@@ -6867,6 +7005,7 @@ fi
......@@ -7474,6 +7613,7 @@ s,@BUILTINS@,$BUILTINS,;t t
s,@PLUGINS@,$PLUGINS,;t t
s,@DEBUG@,$DEBUG,;t t
s,@PROFILING@,$PROFILING,;t t
s,@SYSLOG@,$SYSLOG,;t t
s,@CCFLAGS@,$CCFLAGS,;t t
s,@DCFLAGS@,$DCFLAGS,;t t
s,@LCFLAGS@,$LCFLAGS,;t t
......@@ -7933,6 +8073,7 @@ system : ${SYS}
architecture : ${ARCH}
debug : ${DEBUG}
profiling : ${PROFILING}
debug : ${SYSLOG}
vls configuration
-----------------
......
......@@ -224,6 +224,26 @@ AC_ARG_ENABLE(profiling,
AC_HELP_STRING(--enable-profiling, Enable profiling mode (default disabled)),
[ if test x$enableval = xyes; then PROFILING=1; fi ])
dnl
dnl SYSLOG
dnl
AC_CHECK_HEADERS(syslog.h, SYSLOG=1, SYSLOG=0)
AC_ARG_ENABLE(syslog,
[ --disable-syslog Logging using syslogd (default enable)],
[ if test x$enableval = xno
then
SYSLOG=0
fi])
if test x$enable_syslog = xyes
then
if test ${SYSLOG} = 0
then
AC_MSG_ERROR([Could not find syslog.h. You can alternately configure
using --disable-syslog])
fi
fi
dnl
dnl DVD module
dnl
......@@ -360,6 +380,7 @@ AC_SUBST(PLUGINS)
AC_SUBST(DEBUG)
AC_SUBST(PROFILING)
AC_SUBST(SYSLOG)
AC_SUBST(CCFLAGS)
AC_SUBST(DCFLAGS)
......@@ -381,6 +402,7 @@ system : ${SYS}
architecture : ${ARCH}
debug : ${DEBUG}
profiling : ${PROFILING}
debug : ${SYSLOG}
vls configuration
-----------------
......
......@@ -8,7 +8,7 @@
url="mailto:asmax@via.ecp.fr" name="&lt;asmax@via.ecp.fr&gt;">
<date>
$Id: vls-guide.sgml,v 1.17 2002/08/09 13:42:32 tooney Exp $
$Id: vls-guide.sgml,v 1.18 2002/08/14 11:13:27 tooney Exp $
</date>
<abstract>
This document describes how to install, configure, and run the VideoLAN Server
......@@ -220,6 +220,11 @@ all options available. Here is an explanation of vls-specific options:
</tscreen>
</tscreen>
<tscreen>
<verb>--disable-syslog</verb>
<tscreen>Disable the logging to syslogd (enabled by default).
</tscreen>
</tscreen>
<tscreen>
<verb>--enable-profiling</verb>
<tscreen>Generate extra code to write profile information suitable for the
analysis program gprof.
......@@ -422,12 +427,22 @@ This section contains application wide settings.
<tscreen>
Name of vls log file. Default is "vls.log"
</tscreen>
<verb>SystemLog = "[disable|enable]"</verb>
<tscreen>
Logging to the SystemLog. Today, only the SystemLog using syslogd is
implemented : compile with ./configure --enable-syslog.
</tscreen>
<verb>ScreenLog = "[disable|enable]"</verb>
<tscreen>
Logging to the console.
</tscreen>
</tscreen>
Example:
<tscreen><verb>
BEGIN "Vls"
LogFile = "vls.log"
SystemLog = "disable"
ScreenLog = "enable"
END
</verb></tscreen>
</sect2>
......
......@@ -2,7 +2,7 @@
* application.cpp: Application class
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: application.cpp,v 1.8 2002/04/27 01:15:57 asmax Exp $
* $Id: application.cpp,v 1.9 2002/08/14 11:13:27 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -40,7 +40,9 @@
#endif
#include <signal.h>
#include <sys/types.h>
#ifdef SYSLOG
#include <syslog.h>
#endif
#include "common.h"
#include "debug.h"
#include "reflect.h"
......@@ -86,6 +88,8 @@ C_Application::C_Application(const C_String& strName) : m_strName(strName)
m_pModuleManager = NULL;
m_bOnStop = false;
m_iLogFlags = LOG_DBGMSG;
}
......@@ -109,7 +113,7 @@ int C_Application::Init(int iArgc, char* paArg[])
// Retrieve global configuration from cmd line and cfg file
// Shortly, this step will build a properties table
int iRc = RetrieveConfig(iArgc, paArg);
// Init the logger
if(!iRc)
{
......@@ -117,13 +121,29 @@ int C_Application::Init(int iArgc, char* paArg[])
C_String strDfltLogFile = m_strName.ToLower() + ".log";
C_String strLogFile = GetSetting(strLogFileSetting, strDfltLogFile);
iRc |= m_cLog.Init(strLogFile);
if (strLogFile != "")
{
iRc |= m_cLog.Init(strLogFile);
m_iLogFlags |= LOG_FILE;
}
}
// Check if System Logging is enabled in the vls.cfg
C_String strSystemLog = GetSetting(m_strName + ".SystemLog", "disable");
if (strSystemLog == "enable")
m_iLogFlags |= LOG_SYSTEM;
// Check if screen Logging is enabled in the vls.cfg
C_String strScrLog = GetSetting(m_strName + ".ScreenLog", "enable");
if (strScrLog == "enable")
m_iLogFlags |= LOG_SCR;
// Register the application object by the logger
if(!iRc)
{
m_hLog = StartLog(m_strName, LOG_DBGMSG | LOG_FILE | LOG_SCR );
m_hLog = StartLog(m_strName, m_iLogFlags );
if(!m_hLog)
iRc = GEN_ERR;
}
......@@ -191,6 +211,15 @@ handle C_Application::StartLog(const C_String& strClientDescr, u8 iFlags)
{
handle hLog = m_cLog.Register(strClientDescr, iFlags);
ASSERT(hLog);
// Init the syslog
if (iFlags & LOG_SYSTEM)
{
#ifdef SYSLOG
openlog("vls", LOG_NOWAIT | LOG_NDELAY | LOG_PID, LOG_USER);
#endif
}
return hLog;
}
......@@ -201,7 +230,17 @@ handle C_Application::StartLog(const C_String& strClientDescr, u8 iFlags)
void C_Application::StopLog(handle hLog)
{
ASSERT(hLog);
// close the syslog
if (m_iLogFlags & LOG_SYSTEM)
{
#ifdef SYSLOG
closelog();
#endif
}
m_cLog.Unregister(hLog);
}
......
......@@ -2,7 +2,7 @@
* application.h: Application class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: application.h,v 1.2 2001/11/21 18:51:02 bozo Exp $
* $Id: application.h,v 1.3 2002/08/14 11:13:27 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -75,6 +75,7 @@ class C_Application
handle StartLog(const C_String& strClientDescr, u8 iFlags);
void StopLog(handle hLog);
void LogMsg(handle hLog, int iLevel, const C_String& strMsg);
int GetLogFlags() {return m_iLogFlags;};
protected:
// All the methods below can be rewritten to fit the special needs of a
......@@ -113,6 +114,8 @@ class C_Application
// Application logs
C_Log m_cLog;
int m_iLogFlags;
bool m_bOnStop;
};
......
......@@ -2,7 +2,7 @@
* log.cpp: Logging method
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: log.cpp,v 1.4 2002/04/10 10:47:18 asmax Exp $
* $Id: log.cpp,v 1.5 2002/08/14 11:13:27 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -38,7 +38,9 @@
#include <stdarg.h>
#include <string.h>
#include <time.h>
#ifdef SYSLOG
#include <syslog.h>
#endif
#include "common.h"
#include "string.h"
#include "vector.h"
......@@ -132,7 +134,11 @@ C_Log::~C_Log()
int C_Log::Init(const C_String& strLogName)
{
int iRc = NO_ERR;
// In principe, Init is called to init the file
// so there is no LOG_FILE flag to check
// to perform what is bellow.
try
{
// Open the log file for writing
......@@ -208,8 +214,14 @@ void C_Log::Unregister(handle hModule)
//------------------------------------------------------------------------------
void C_Log::Append(handle hModule, u8 iLevel, const C_String& strMsg)
{
time_t tTime;
struct tm* ptmTime;
time(&tTime);
ptmTime = localtime(&tTime);
C_String strBuff("");
ASSERT(hModule); // Verify that the module is well registered
ASSERT(m_pLogFile); // Verify that Init() has been called before
#define pClient ((C_LogClient*)hModule)
......@@ -222,32 +234,29 @@ void C_Log::Append(handle hModule, u8 iLevel, const C_String& strMsg)
// The message must be logged: add the necessary fields
// First record the time
time_t tTime;
struct tm* ptmTime;
time(&tTime);
ptmTime = localtime(&tTime);
C_String strBuff(1900 + ptmTime->tm_year);
strBuff += "-";
C_String StrDateBuff(1900 + ptmTime->tm_year);
StrDateBuff += "-";
if(ptmTime->tm_mon < 9)
strBuff += "0";
strBuff += 1 + ptmTime->tm_mon;
strBuff += "-";
StrDateBuff += "0";
StrDateBuff += 1 + ptmTime->tm_mon;
StrDateBuff += "-";
if(ptmTime->tm_mday < 10)
strBuff += "0";
strBuff += ptmTime->tm_mday;
strBuff += " ";
StrDateBuff += "0";
StrDateBuff += ptmTime->tm_mday;
StrDateBuff += " ";
if(ptmTime->tm_hour < 10)
strBuff += "0";
strBuff += ptmTime->tm_hour;
strBuff += ":";
if(ptmTime->tm_min < 10)
strBuff += "0";
strBuff += ptmTime->tm_min;
strBuff += ":";
if(ptmTime->tm_sec < 10)
strBuff += "0";
strBuff += ptmTime->tm_sec;
strBuff += " ";
StrDateBuff += "0";
StrDateBuff += ptmTime->tm_hour;
StrDateBuff += ":";
if(ptmTime->tm_min < 10)
StrDateBuff += "0";
StrDateBuff += ptmTime->tm_min;
StrDateBuff += ":";
if(ptmTime->tm_sec < 10)
StrDateBuff += "0";
StrDateBuff += ptmTime->tm_sec;
StrDateBuff += " ";
// Indicate the severity level of the message
switch (iLevel)
......@@ -280,9 +289,20 @@ void C_Log::Append(handle hModule, u8 iLevel, const C_String& strMsg)
// Add the final CR
strBuff += "\n";
if (pClient->iFlags & LOG_SYSTEM)
{
#ifdef SYSLOG
syslog(LOG_INFO,strBuff.GetString());
#endif
}
strBuff = StrDateBuff + strBuff;
// Now check to what devices the message must be outputed
if(pClient->iFlags & LOG_FILE)
{
ASSERT(m_pLogFile); // Verify that Init() has been called before
// Append the buffer to the logfile and discards errors
const char* pszBuff = strBuff.GetString();
int iLen = strBuff.Length();
......@@ -293,7 +313,8 @@ void C_Log::Append(handle hModule, u8 iLevel, const C_String& strMsg)
catch(E_Exception e)
{};
}
if(pClient->iFlags & LOG_SCR)
if (pClient->iFlags & LOG_SCR)
{
// Print the message to stderr
fprintf(stderr, "%s", strBuff.GetString());
......
......@@ -2,7 +2,7 @@
* log.h: Log class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: log.h,v 1.1 2001/10/06 21:23:36 bozo Exp $
* $Id: log.h,v 1.2 2002/08/14 11:13:27 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -55,7 +55,7 @@
// Four other bytes are used to ???
#define LOG_FILE 16 // Append message to the log file
#define LOG_SCR 32 // Log must be send to stderr
//#define LOG_SYSLOG 64 // Send message to the syslog daemon
#define LOG_SYSTEM 64 // Send message to the system Log
//------------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* input.cpp: Input streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: input.cpp,v 1.4 2002/08/09 13:42:32 tooney Exp $
* $Id: input.cpp,v 1.5 2002/08/14 11:13:27 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -140,7 +140,7 @@ void C_Input::Init()
ASSERT(pApp);
// First register the source as a log client
m_hLog = pApp->StartLog(m_strName, LOG_DBGMSG|LOG_FILE|LOG_SCR);
m_hLog = pApp->StartLog(m_strName, pApp->GetLogFlags());
ASSERT(m_hLog);
// Now call the child's initialisation method
......
......@@ -2,7 +2,7 @@
* telnet.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: telnet.cpp,v 1.6 2002/07/16 22:12:36 sam Exp $
* $Id: telnet.cpp,v 1.7 2002/08/14 11:13:27 tooney Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -410,7 +410,7 @@ void C_TelnetSession::ProcessData()
case IAC:
{
// Telnet negociation or special char
printf("negociation: %x %x\n", cData[iPos+1], cData[iPos+2]);
// printf("negociation: %x %x\n", cData[iPos+1], cData[iPos+2]);
m_cBuffer[0] = IAC;
m_cBuffer.SetSize(1);
m_iMode = CONFIG_MODE;
......@@ -420,7 +420,7 @@ void C_TelnetSession::ProcessData()
case TELOPT_OUTMRK:
{
// Telnet special chars
printf("output marking: %x %x\n", cData[iPos+1], cData[iPos+2]);
// printf("output marking: %x %x\n", cData[iPos+1], cData[iPos+2]);
m_cBuffer[0] = TELOPT_OUTMRK;
m_cBuffer.SetSize(1);
m_iMode = CONTROL_MODE;
......
......@@ -3,6 +3,8 @@
# Application wide settings
BEGIN "Vls"
LogFile = "vls.log" # log file
ScreenLog = "enable" # log to the console
SystemLog = "disable" # log to the systemlog
END
# Security informations :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment