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
|
||||
|
||||
!SUBSECTION Logfile
|
||||
<!-- lib/ApplicationServer/ApplicationServer.h -->
|
||||
@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.
|
||||
|
||||
`--log.tty filename`
|
||||
|
||||
Be default, if started on a tty, the log output will also go to the ttyp.
|
||||
Use *""* to disable.
|
||||
|
||||
!SUBSECTION Request
|
||||
<!-- lib/ApplicationServer/ApplicationServer.h -->
|
||||
|
|
|
@ -97,86 +97,50 @@ string const ApplicationServer::OPTIONS_SSL = "SSL Options";
|
|||
/// @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
|
||||
|
||||
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),
|
||||
_finishedCondition() {
|
||||
}
|
||||
|
||||
#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),
|
||||
_finishedCondition() {
|
||||
storeRealPrivileges();
|
||||
}
|
||||
|
||||
#endif
|
||||
_finishedCondition() {
|
||||
#ifndef _WIN32
|
||||
storeRealPrivileges();
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
|
@ -227,7 +191,7 @@ string const& ApplicationServer::getName () const {
|
|||
/// @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_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
|
||||
if (! _logFacility.empty()) {
|
||||
TRI_CreateLogAppenderSyslog(_logApplicationName.c_str(),
|
||||
|
@ -446,7 +423,7 @@ bool ApplicationServer::parse (int argc,
|
|||
// setup logging
|
||||
// .............................................................................
|
||||
|
||||
setupLogging(false, false);
|
||||
setupLogging(false, false, false);
|
||||
|
||||
// .............................................................................
|
||||
// parse phase 2
|
||||
|
@ -811,7 +788,7 @@ void ApplicationServer::setupOptions (map<string, ProgramOptionsDescription>& op
|
|||
options[OPTIONS_LOGGER]
|
||||
("log.file", &_logFile, "log 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"]
|
||||
|
@ -824,6 +801,7 @@ void ApplicationServer::setupOptions (map<string, ProgramOptionsDescription>& op
|
|||
("log.severity", &_logSeverity, "log severities")
|
||||
("log.thread", "log the thread identifier for severity 'human'")
|
||||
("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]
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace triagens {
|
|||
/// @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
|
||||
|
@ -660,22 +660,17 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief log file
|
||||
/// @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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string _logFile;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief log file
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string _logTty;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief log file for requests
|
||||
/// @startDocuBlock logRequests
|
||||
|
|
|
@ -274,7 +274,7 @@ int AnyServer::start () {
|
|||
return startupDaemon();
|
||||
}
|
||||
else {
|
||||
_applicationServer->setupLogging(true, false);
|
||||
_applicationServer->setupLogging(true, false, false);
|
||||
|
||||
if (! _pidFile.empty()) {
|
||||
CheckPidFile(_pidFile);
|
||||
|
@ -331,7 +331,7 @@ int AnyServer::startupSupervisor () {
|
|||
|
||||
CheckPidFile(_pidFile);
|
||||
|
||||
_applicationServer->setupLogging(false, true);
|
||||
_applicationServer->setupLogging(false, true, true);
|
||||
|
||||
string current;
|
||||
int result = forkProcess(_workingDirectory, current);
|
||||
|
@ -359,7 +359,7 @@ int AnyServer::startupSupervisor () {
|
|||
|
||||
// parent
|
||||
if (0 < pid) {
|
||||
_applicationServer->setupLogging(false, true);
|
||||
_applicationServer->setupLogging(false, true, true);
|
||||
TRI_SetProcessTitle("arangodb [supervisor]");
|
||||
|
||||
int status;
|
||||
|
@ -430,7 +430,7 @@ int AnyServer::startupSupervisor () {
|
|||
|
||||
// child
|
||||
else {
|
||||
_applicationServer->setupLogging(true, false);
|
||||
_applicationServer->setupLogging(true, false, true);
|
||||
|
||||
// write the pid file
|
||||
WritePidFile(_pidFile, TRI_CurrentProcessId());
|
||||
|
@ -467,7 +467,7 @@ int AnyServer::startupDaemon () {
|
|||
|
||||
CheckPidFile(_pidFile);
|
||||
|
||||
_applicationServer->setupLogging(false, true);
|
||||
_applicationServer->setupLogging(false, true, true);
|
||||
|
||||
string current;
|
||||
int result = forkProcess(_workingDirectory, current);
|
||||
|
@ -483,7 +483,7 @@ int AnyServer::startupDaemon () {
|
|||
|
||||
// child process
|
||||
else {
|
||||
_applicationServer->setupLogging(true, false);
|
||||
_applicationServer->setupLogging(true, false, true);
|
||||
|
||||
// and startup server
|
||||
prepareServer();
|
||||
|
|
Loading…
Reference in New Issue