mirror of https://gitee.com/bigwinds/arangodb
log to stderr if on a tty
This commit is contained in:
parent
b4ba07f765
commit
0a0eebb33f
|
@ -8,8 +8,22 @@ statistics about executed requests and timings about computation steps.
|
||||||
!SECTION General Logging Options
|
!SECTION General Logging Options
|
||||||
|
|
||||||
!SUBSECTION Logfile
|
!SUBSECTION Logfile
|
||||||
<!-- lib/ApplicationServer/ApplicationServer.h -->
|
`--log.file filename`
|
||||||
@startDocuBlock logFile
|
|
||||||
|
This option allows the user to specify the name of a file to which information
|
||||||
|
is logged. By default, if no log file is specified, the standard output is
|
||||||
|
used. Note that if the file named by *filename* does not exist, it will be
|
||||||
|
created. If the file cannot be created (e.g. due to missing file privileges),
|
||||||
|
the server will refuse to start. If the specified file already exists, output is
|
||||||
|
appended to that file.
|
||||||
|
|
||||||
|
Use *+* to log to standard error. Use *-* to log to standard output.
|
||||||
|
Use *""* to disable logging to file.
|
||||||
|
|
||||||
|
`--log.tty filename`
|
||||||
|
|
||||||
|
Be default, if started on a tty, the log output will also go to the ttyp.
|
||||||
|
Use *""* to disable.
|
||||||
|
|
||||||
!SUBSECTION Request
|
!SUBSECTION Request
|
||||||
<!-- lib/ApplicationServer/ApplicationServer.h -->
|
<!-- lib/ApplicationServer/ApplicationServer.h -->
|
||||||
|
|
|
@ -97,86 +97,50 @@ string const ApplicationServer::OPTIONS_SSL = "SSL Options";
|
||||||
/// @brief constructor
|
/// @brief constructor
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ApplicationServer::ApplicationServer (std::string const& name, std::string const& title, std::string const& version)
|
||||||
|
: _options(),
|
||||||
|
_description(),
|
||||||
|
_descriptionFile(),
|
||||||
|
_arguments(),
|
||||||
|
_features(),
|
||||||
|
_exitOnParentDeath(false),
|
||||||
|
_watchParent(0),
|
||||||
|
_stopping(0),
|
||||||
|
_name(name),
|
||||||
|
_title(title),
|
||||||
|
_version(version),
|
||||||
|
_configFile(),
|
||||||
|
_userConfigFile(),
|
||||||
|
_systemConfigFile(),
|
||||||
|
_uid(),
|
||||||
|
_realUid(0),
|
||||||
|
_effectiveUid(0),
|
||||||
|
_gid(),
|
||||||
|
_realGid(0),
|
||||||
|
_effectiveGid(0),
|
||||||
|
_logApplicationName("arangod"),
|
||||||
|
_logFacility(""),
|
||||||
|
_logLevel("info"),
|
||||||
|
_logSeverity("human"),
|
||||||
|
_logFile("+"),
|
||||||
|
_logTty("+"),
|
||||||
|
_logRequestsFile(""),
|
||||||
|
_logPrefix(),
|
||||||
|
_logThreadId(false),
|
||||||
|
_logLineNumber(false),
|
||||||
|
_logLocalTime(false),
|
||||||
|
_logSourceFilter(),
|
||||||
|
_logContentFilter(),
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
ApplicationServer::ApplicationServer (std::string const& name, std::string const& title, std::string const& version)
|
|
||||||
: _options(),
|
|
||||||
_description(),
|
|
||||||
_descriptionFile(),
|
|
||||||
_arguments(),
|
|
||||||
_features(),
|
|
||||||
_exitOnParentDeath(false),
|
|
||||||
_watchParent(0),
|
|
||||||
_stopping(0),
|
|
||||||
_name(name),
|
|
||||||
_title(title),
|
|
||||||
_version(version),
|
|
||||||
_configFile(),
|
|
||||||
_userConfigFile(),
|
|
||||||
_systemConfigFile(),
|
|
||||||
_uid(),
|
|
||||||
_realUid(0),
|
|
||||||
_effectiveUid(0),
|
|
||||||
_gid(),
|
|
||||||
_realGid(0),
|
|
||||||
_effectiveGid(0),
|
|
||||||
_logApplicationName("arangod"),
|
|
||||||
_logFacility(""),
|
|
||||||
_logLevel("info"),
|
|
||||||
_logSeverity("human"),
|
|
||||||
_logFile("+"),
|
|
||||||
_logRequestsFile(""),
|
|
||||||
_logPrefix(),
|
|
||||||
_logThreadId(false),
|
|
||||||
_logLineNumber(false),
|
|
||||||
_logLocalTime(false),
|
|
||||||
_logSourceFilter(),
|
|
||||||
_logContentFilter(),
|
|
||||||
_randomGenerator(5),
|
_randomGenerator(5),
|
||||||
_finishedCondition() {
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
ApplicationServer::ApplicationServer (std::string const& name, std::string const& title, std::string const& version)
|
|
||||||
: _options(),
|
|
||||||
_description(),
|
|
||||||
_descriptionFile(),
|
|
||||||
_arguments(),
|
|
||||||
_features(),
|
|
||||||
_exitOnParentDeath(false),
|
|
||||||
_watchParent(0),
|
|
||||||
_stopping(0),
|
|
||||||
_name(name),
|
|
||||||
_title(title),
|
|
||||||
_version(version),
|
|
||||||
_configFile(),
|
|
||||||
_userConfigFile(),
|
|
||||||
_systemConfigFile(),
|
|
||||||
_uid(),
|
|
||||||
_realUid(0),
|
|
||||||
_effectiveUid(0),
|
|
||||||
_gid(),
|
|
||||||
_realGid(0),
|
|
||||||
_effectiveGid(0),
|
|
||||||
_logApplicationName("arangod"),
|
|
||||||
_logFacility(""),
|
|
||||||
_logLevel("info"),
|
|
||||||
_logSeverity("human"),
|
|
||||||
_logFile("+"),
|
|
||||||
_logRequestsFile(""),
|
|
||||||
_logPrefix(),
|
|
||||||
_logThreadId(false),
|
|
||||||
_logLineNumber(false),
|
|
||||||
_logLocalTime(false),
|
|
||||||
_logSourceFilter(),
|
|
||||||
_logContentFilter(),
|
|
||||||
_randomGenerator(3),
|
_randomGenerator(3),
|
||||||
_finishedCondition() {
|
|
||||||
storeRealPrivileges();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
_finishedCondition() {
|
||||||
|
#ifndef _WIN32
|
||||||
|
storeRealPrivileges();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief destructor
|
/// @brief destructor
|
||||||
|
@ -227,7 +191,7 @@ string const& ApplicationServer::getName () const {
|
||||||
/// @brief sets up the logging
|
/// @brief sets up the logging
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void ApplicationServer::setupLogging (bool threaded, bool daemon) {
|
void ApplicationServer::setupLogging (bool threaded, bool daemon, bool backgrounded) {
|
||||||
TRI_ShutdownLogging(false);
|
TRI_ShutdownLogging(false);
|
||||||
TRI_InitialiseLogging(threaded);
|
TRI_InitialiseLogging(threaded);
|
||||||
|
|
||||||
|
@ -305,6 +269,19 @@ void ApplicationServer::setupLogging (bool threaded, bool daemon) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// additional log file in case of tty
|
||||||
|
if (! backgrounded && isatty(STDOUT_FILENO) != 0 && ! _logTty.empty()) {
|
||||||
|
bool regularOut = (_logFile == "+" || _logFile == "-");
|
||||||
|
bool ttyOut = (_logTty == "+" || _logTty == "-");
|
||||||
|
|
||||||
|
if (! regularOut || ! ttyOut) {
|
||||||
|
TRI_CreateLogAppenderFile(_logTty.c_str(),
|
||||||
|
contentFilter,
|
||||||
|
TRI_LOG_SEVERITY_UNKNOWN,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef TRI_ENABLE_SYSLOG
|
#ifdef TRI_ENABLE_SYSLOG
|
||||||
if (! _logFacility.empty()) {
|
if (! _logFacility.empty()) {
|
||||||
TRI_CreateLogAppenderSyslog(_logApplicationName.c_str(),
|
TRI_CreateLogAppenderSyslog(_logApplicationName.c_str(),
|
||||||
|
@ -446,7 +423,7 @@ bool ApplicationServer::parse (int argc,
|
||||||
// setup logging
|
// setup logging
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
setupLogging(false, false);
|
setupLogging(false, false, false);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// parse phase 2
|
// parse phase 2
|
||||||
|
@ -811,7 +788,7 @@ void ApplicationServer::setupOptions (map<string, ProgramOptionsDescription>& op
|
||||||
options[OPTIONS_LOGGER]
|
options[OPTIONS_LOGGER]
|
||||||
("log.file", &_logFile, "log to file")
|
("log.file", &_logFile, "log to file")
|
||||||
("log.requests-file", &_logRequestsFile, "log requests to file")
|
("log.requests-file", &_logRequestsFile, "log requests to file")
|
||||||
("log.level,l", &_logLevel, "log level for severity 'human'")
|
("log.level,l", &_logLevel, "log level")
|
||||||
;
|
;
|
||||||
|
|
||||||
options[OPTIONS_LOGGER + ":help-log"]
|
options[OPTIONS_LOGGER + ":help-log"]
|
||||||
|
@ -824,6 +801,7 @@ void ApplicationServer::setupOptions (map<string, ProgramOptionsDescription>& op
|
||||||
("log.severity", &_logSeverity, "log severities")
|
("log.severity", &_logSeverity, "log severities")
|
||||||
("log.thread", "log the thread identifier for severity 'human'")
|
("log.thread", "log the thread identifier for severity 'human'")
|
||||||
("log.use-local-time", "use local dates and times in log messages")
|
("log.use-local-time", "use local dates and times in log messages")
|
||||||
|
("log.tty", &_logTty, "additional log file if started on tty")
|
||||||
;
|
;
|
||||||
|
|
||||||
options[OPTIONS_HIDDEN]
|
options[OPTIONS_HIDDEN]
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace triagens {
|
||||||
/// @brief sets up the logging
|
/// @brief sets up the logging
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void setupLogging (bool thread, bool daemon);
|
void setupLogging (bool thread, bool daemon, bool backgrounded);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief returns the command line options
|
/// @brief returns the command line options
|
||||||
|
@ -660,22 +660,17 @@ namespace triagens {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief log file
|
/// @brief log file
|
||||||
/// @startDocuBlock logFile
|
/// @startDocuBlock logFile
|
||||||
/// `--log.file filename`
|
|
||||||
///
|
|
||||||
/// This option allows the user to specify the name of a file to which
|
|
||||||
/// information is logged. By default, if no log file is specified, the standard
|
|
||||||
/// output is used. Note that if the file named by *filename* does not
|
|
||||||
/// exist, it will be created. If the file cannot be created (e.g. due to
|
|
||||||
/// missing file privileges), the server will refuse to start. If the specified
|
|
||||||
/// file already exists, output is appended to that file.
|
|
||||||
///
|
|
||||||
/// Use *+* to log to standard error. Use *-* to log to standard output.
|
|
||||||
/// Use *""* to disable logging to file.
|
|
||||||
/// @endDocuBlock
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string _logFile;
|
std::string _logFile;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief log file
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string _logTty;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief log file for requests
|
/// @brief log file for requests
|
||||||
/// @startDocuBlock logRequests
|
/// @startDocuBlock logRequests
|
||||||
|
|
|
@ -274,7 +274,7 @@ int AnyServer::start () {
|
||||||
return startupDaemon();
|
return startupDaemon();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_applicationServer->setupLogging(true, false);
|
_applicationServer->setupLogging(true, false, false);
|
||||||
|
|
||||||
if (! _pidFile.empty()) {
|
if (! _pidFile.empty()) {
|
||||||
CheckPidFile(_pidFile);
|
CheckPidFile(_pidFile);
|
||||||
|
@ -331,7 +331,7 @@ int AnyServer::startupSupervisor () {
|
||||||
|
|
||||||
CheckPidFile(_pidFile);
|
CheckPidFile(_pidFile);
|
||||||
|
|
||||||
_applicationServer->setupLogging(false, true);
|
_applicationServer->setupLogging(false, true, true);
|
||||||
|
|
||||||
string current;
|
string current;
|
||||||
int result = forkProcess(_workingDirectory, current);
|
int result = forkProcess(_workingDirectory, current);
|
||||||
|
@ -359,7 +359,7 @@ int AnyServer::startupSupervisor () {
|
||||||
|
|
||||||
// parent
|
// parent
|
||||||
if (0 < pid) {
|
if (0 < pid) {
|
||||||
_applicationServer->setupLogging(false, true);
|
_applicationServer->setupLogging(false, true, true);
|
||||||
TRI_SetProcessTitle("arangodb [supervisor]");
|
TRI_SetProcessTitle("arangodb [supervisor]");
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
|
@ -430,7 +430,7 @@ int AnyServer::startupSupervisor () {
|
||||||
|
|
||||||
// child
|
// child
|
||||||
else {
|
else {
|
||||||
_applicationServer->setupLogging(true, false);
|
_applicationServer->setupLogging(true, false, true);
|
||||||
|
|
||||||
// write the pid file
|
// write the pid file
|
||||||
WritePidFile(_pidFile, TRI_CurrentProcessId());
|
WritePidFile(_pidFile, TRI_CurrentProcessId());
|
||||||
|
@ -467,7 +467,7 @@ int AnyServer::startupDaemon () {
|
||||||
|
|
||||||
CheckPidFile(_pidFile);
|
CheckPidFile(_pidFile);
|
||||||
|
|
||||||
_applicationServer->setupLogging(false, true);
|
_applicationServer->setupLogging(false, true, true);
|
||||||
|
|
||||||
string current;
|
string current;
|
||||||
int result = forkProcess(_workingDirectory, current);
|
int result = forkProcess(_workingDirectory, current);
|
||||||
|
@ -483,7 +483,7 @@ int AnyServer::startupDaemon () {
|
||||||
|
|
||||||
// child process
|
// child process
|
||||||
else {
|
else {
|
||||||
_applicationServer->setupLogging(true, false);
|
_applicationServer->setupLogging(true, false, true);
|
||||||
|
|
||||||
// and startup server
|
// and startup server
|
||||||
prepareServer();
|
prepareServer();
|
||||||
|
|
Loading…
Reference in New Issue