mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
[#1671] Added command line switches for daemon
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
dnl SFLPhone - configure.ac for automake 1.9 and autoconf 2.59
|
||||
dnl
|
||||
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT([sflphone],[0.9.7~beta],[sflphoneteam@savoirfairelinux.com],[sflphone])
|
||||
@ -8,14 +9,17 @@ AC_REVISION([$Revision$])
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
|
||||
PACKAGE=SFLphone
|
||||
VERSION=`cat VERSION`
|
||||
|
||||
AM_INIT_AUTOMAKE($NAME, $VERSION)
|
||||
AM_CONFIG_HEADER([config.h])
|
||||
|
||||
# Silent build by default. Use make V=1 to increase verbosity
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||
|
||||
dnl Use this variable in the program
|
||||
AC_SUBST(PACKAGE_VERSION)
|
||||
AC_SUBST(PACKAGE_VERSION)
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
|
@ -30,6 +30,7 @@ endif
|
||||
|
||||
sflphoned_CXXFLAGS = \
|
||||
-DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(IAX_CXXFLAG)\
|
||||
-DVERSION=\"$(VERSION)\" \
|
||||
@ZRTPCPP_CFLAGS@ \
|
||||
@libssl_CFLAGS@
|
||||
|
||||
|
@ -2,8 +2,17 @@
|
||||
#include <syslog.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void Logger::log(const int level, const char* format, ...)
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
bool consoleLog = false;
|
||||
bool debugMode = false;
|
||||
|
||||
void log(const int level, const char* format, ...)
|
||||
{
|
||||
if(!debugMode && level == LOG_DEBUG)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
string prefix = "<> ";
|
||||
char buffer[1024];
|
||||
@ -47,7 +56,22 @@ void Logger::log(const int level, const char* format, ...)
|
||||
|
||||
syslog(level, message.c_str());
|
||||
|
||||
message = color_prefix + message + END_COLOR + "\n";
|
||||
fprintf(stderr, message.c_str());
|
||||
if(consoleLog)
|
||||
{
|
||||
message = color_prefix + message + END_COLOR + "\n";
|
||||
fprintf(stderr, message.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void setConsoleLog(bool c)
|
||||
{
|
||||
Logger::consoleLog = c;
|
||||
}
|
||||
|
||||
void setDebugMode(bool d)
|
||||
{
|
||||
Logger::debugMode = d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,9 @@ using namespace std;
|
||||
namespace Logger
|
||||
{
|
||||
void log(const int, const char*, ...);
|
||||
|
||||
void setConsoleLog(bool);
|
||||
void setDebugMode(bool);
|
||||
};
|
||||
|
||||
#define _error(...) Logger::log(LOG_ERROR, __VA_ARGS__)
|
||||
@ -16,9 +19,9 @@ namespace Logger
|
||||
#define _info(...) Logger::log(LOG_INFO, __VA_ARGS__)
|
||||
#define _debug(...) Logger::log(LOG_DEBUG, __VA_ARGS__)
|
||||
|
||||
#define _debugException(...)
|
||||
#define _debugInit(...)
|
||||
#define _debugAlsa(...)
|
||||
#define _debugException(...) Logger::log(LOG_DEBUG, __VA_ARGS__)
|
||||
#define _debugInit(...) Logger::log(LOG_DEBUG, __VA_ARGS__)
|
||||
#define _debugAlsa(...) Logger::log(LOG_DEBUG, __VA_ARGS__)
|
||||
|
||||
#define BLACK "\033[22;30m"
|
||||
#define RED "\033[22;31m"
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <string>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
//#include "config.h"
|
||||
#include <cc++/common.h>
|
||||
#include "global.h"
|
||||
|
||||
#include "user_cfg.h"
|
||||
@ -34,25 +34,63 @@
|
||||
|
||||
#include "audio/audiolayer.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ost;
|
||||
|
||||
CommandOptionArg level(
|
||||
"log-level", "l", "Log level (not yet implemented)"
|
||||
);
|
||||
|
||||
CommandOptionNoArg console(
|
||||
"console", "c", "Log in console (instead of syslog)"
|
||||
);
|
||||
|
||||
CommandOptionNoArg debug(
|
||||
"debug", "d", "Debug mode (more verbose)"
|
||||
);
|
||||
|
||||
CommandOptionNoArg help(
|
||||
"help", "h", "Print help"
|
||||
);
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int exit_code = 0;
|
||||
int exit_code = 0;
|
||||
|
||||
//setlocale (LC_ALL, "");
|
||||
//bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
//textdomain (PACKAGE);
|
||||
Logger::setConsoleLog(false);
|
||||
Logger::setDebugMode(false);
|
||||
|
||||
if (argc == 2 && strcmp (argv[1], "--help") == 0) {
|
||||
CommandOptionParse * args = makeCommandOptionParse(argc, argv, "");
|
||||
|
||||
printf ("SFLphone Daemon %s, by Savoir-Faire Linux 2004-2009\n", VERSION);
|
||||
printf ("http://www.sflphone.org/\n");
|
||||
|
||||
printf ("%1$s Daemon %2$s, by Savoir-Faire Linux 2004-2009",
|
||||
PROGNAME,
|
||||
SFLPHONED_VERSION);
|
||||
printf ("USAGE: sflphoned [--help]Parameters: --help\tfor this message --port=3999\tchange the session port");
|
||||
printf ("See http://www.sflphone.org/ for more information");
|
||||
if ( help.numSet ) {
|
||||
cerr << args->printUsage();
|
||||
::exit(0);
|
||||
}
|
||||
|
||||
if ( args->argsHaveError() ) {
|
||||
cerr << args->printErrors();
|
||||
cerr << args->printUsage();
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
if( console.numSet )
|
||||
{
|
||||
_info("Console logging activated");
|
||||
Logger::setConsoleLog(true);
|
||||
}
|
||||
|
||||
if( debug.numSet )
|
||||
{
|
||||
_info("Debug mode activated");
|
||||
Logger::setDebugMode(true);
|
||||
}
|
||||
|
||||
delete args;
|
||||
|
||||
} else {
|
||||
FILE *fp;
|
||||
char homepid[128];
|
||||
char sfldir[128];
|
||||
@ -163,7 +201,6 @@ main (int argc, char **argv)
|
||||
Manager::instance().setDBusManager (&DBusManager::instance());
|
||||
exit_code = DBusManager::instance().exec(); // UI Loop
|
||||
}
|
||||
}
|
||||
|
||||
return exit_code;
|
||||
}
|
||||
|
Reference in New Issue
Block a user