Added no_time_stamp_ms option mainly for testing
This commit is contained in:
committed by
Andrew Gaul
parent
5debf523b0
commit
a0f347b10f
@ -370,6 +370,11 @@ Specify "normal" or "body" for the parameter.
|
||||
If the parameter is omitted, it is the same as "normal".
|
||||
If "body" is specified, some API communication body data will be output in addition to the debug message output as "normal".
|
||||
.TP
|
||||
\fB\-o\fR no_time_stamp_msg - no time stamp in debug message
|
||||
The time stamp is output to the debug message by default.
|
||||
If this option is specified, the time stamp will not be output in the debug message.
|
||||
It is the same even if the environment variable "S3FS_MSGTIMESTAMP" is set to "no".
|
||||
.TP
|
||||
\fB\-o\fR set_check_cache_sigusr1 (default is stdout)
|
||||
If the cache is enabled, you can check the integrity of the cache file and the cache file's stats info file.
|
||||
This option is specified and when sending the SIGUSR1 signal to the s3fs process checks the cache status at that time.
|
||||
|
||||
@ -4742,6 +4742,13 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// no time stamp in debug message
|
||||
//
|
||||
if(0 == strcmp(arg, "no_time_stamp_msg")){
|
||||
S3fsLog::SetTimeStamp(false);
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Check cache file, using SIGUSR1
|
||||
//
|
||||
if(0 == strcmp(arg, "set_check_cache_sigusr1")){
|
||||
|
||||
@ -472,6 +472,13 @@ static const char help_string[] =
|
||||
" If \"body\" is specified, some API communication body data will be\n"
|
||||
" output in addition to the debug message output as \"normal\".\n"
|
||||
"\n"
|
||||
" no_time_stamp_msg - no time stamp in debug message\n"
|
||||
" The time stamp is output to the debug message by default.\n"
|
||||
" If this option is specified, the time stamp will not be output\n"
|
||||
" in the debug message.\n"
|
||||
" It is the same even if the environment variable \"S3FS_MSGTIMESTAMP\"\n"
|
||||
" is set to \"no\".\n"
|
||||
"\n"
|
||||
" set_check_cache_sigusr1 (default is stdout)\n"
|
||||
" If the cache is enabled, you can check the integrity of the\n"
|
||||
" cache file and the cache file's stats info file.\n"
|
||||
|
||||
@ -30,11 +30,13 @@
|
||||
const int S3fsLog::NEST_MAX;
|
||||
const char* S3fsLog::nest_spaces[S3fsLog::NEST_MAX] = {"", " ", " ", " "};
|
||||
const char* S3fsLog::LOGFILEENV = "S3FS_LOGFILE";
|
||||
const char* S3fsLog::MSGTIMESTAMP = "S3FS_MSGTIMESTAMP";
|
||||
S3fsLog* S3fsLog::pSingleton = NULL;
|
||||
S3fsLog::s3fs_log_level S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
||||
FILE* S3fsLog::logfp = NULL;
|
||||
std::string* S3fsLog::plogfile = NULL;
|
||||
char S3fsLog::current_time[64] = "";
|
||||
bool S3fsLog::time_stamp = true;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// S3fsLog class : class methods
|
||||
@ -89,6 +91,13 @@ S3fsLog::s3fs_log_level S3fsLog::BumpupLogLevel()
|
||||
return S3fsLog::pSingleton->LowBumpupLogLevel();
|
||||
}
|
||||
|
||||
bool S3fsLog::SetTimeStamp(bool value)
|
||||
{
|
||||
bool old = S3fsLog::time_stamp;
|
||||
S3fsLog::time_stamp = value;
|
||||
return old;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// S3fsLog class : methods
|
||||
//-------------------------------------------------------------------
|
||||
@ -133,11 +142,19 @@ bool S3fsLog::LowLoadEnv()
|
||||
return false;
|
||||
}
|
||||
char* pEnvVal;
|
||||
if(NULL == (pEnvVal = getenv(S3fsLog::LOGFILEENV))){
|
||||
return true;
|
||||
if(NULL != (pEnvVal = getenv(S3fsLog::LOGFILEENV))){
|
||||
if(!SetLogfile(pEnvVal)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!SetLogfile(pEnvVal)){
|
||||
return false;
|
||||
if(NULL != (pEnvVal = getenv(S3fsLog::MSGTIMESTAMP))){
|
||||
if(0 == strcasecmp(pEnvVal, "true") || 0 == strcasecmp(pEnvVal, "yes") || 0 == strcasecmp(pEnvVal, "1")){
|
||||
S3fsLog::time_stamp = true;
|
||||
}else if(0 == strcasecmp(pEnvVal, "false") || 0 == strcasecmp(pEnvVal, "no") || 0 == strcasecmp(pEnvVal, "0")){
|
||||
S3fsLog::time_stamp = false;
|
||||
}else{
|
||||
S3FS_PRN_WARN("Unknown %s environment value(%s) is specified, skip to set time stamp mode.", S3fsLog::MSGTIMESTAMP, pEnvVal);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -33,9 +33,9 @@
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define S3FSLOG_TIME_FMT "%s.%03dZ"
|
||||
#define S3FSLOG_TIME_FMT "%s.%03dZ "
|
||||
#else
|
||||
#define S3FSLOG_TIME_FMT "%s.%03ldZ"
|
||||
#define S3FSLOG_TIME_FMT "%s.%03ldZ "
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@ -56,11 +56,13 @@ class S3fsLog
|
||||
static const int NEST_MAX = 4;
|
||||
static const char* nest_spaces[NEST_MAX];
|
||||
static const char* LOGFILEENV;
|
||||
static const char* MSGTIMESTAMP;
|
||||
static S3fsLog* pSingleton;
|
||||
static s3fs_log_level debug_level;
|
||||
static FILE* logfp;
|
||||
static std::string* plogfile;
|
||||
static char current_time[64];
|
||||
static bool time_stamp;
|
||||
|
||||
protected:
|
||||
bool LowLoadEnv();
|
||||
@ -86,18 +88,22 @@ class S3fsLog
|
||||
|
||||
static const char* GetCurrentTime()
|
||||
{
|
||||
struct timeval now;
|
||||
struct timespec tsnow;
|
||||
struct tm res;
|
||||
char tmp[32];
|
||||
if(-1 == clock_gettime(S3FS_CLOCK_MONOTONIC, &tsnow)){
|
||||
now.tv_sec = tsnow.tv_sec;
|
||||
now.tv_usec = (tsnow.tv_nsec / 1000);
|
||||
if(time_stamp){
|
||||
struct timeval now;
|
||||
struct timespec tsnow;
|
||||
struct tm res;
|
||||
char tmp[32];
|
||||
if(-1 == clock_gettime(S3FS_CLOCK_MONOTONIC, &tsnow)){
|
||||
now.tv_sec = tsnow.tv_sec;
|
||||
now.tv_usec = (tsnow.tv_nsec / 1000);
|
||||
}else{
|
||||
gettimeofday(&now, NULL);
|
||||
}
|
||||
strftime(tmp, sizeof(tmp), "%Y-%m-%dT%H:%M:%S", gmtime_r(&now.tv_sec, &res));
|
||||
snprintf(current_time, sizeof(current_time), S3FSLOG_TIME_FMT, tmp, (now.tv_usec / 1000));
|
||||
}else{
|
||||
gettimeofday(&now, NULL);
|
||||
current_time[0] = '\0';
|
||||
}
|
||||
strftime(tmp, sizeof(tmp), "%Y-%m-%dT%H:%M:%S", gmtime_r(&now.tv_sec, &res));
|
||||
snprintf(current_time, sizeof(current_time), S3FSLOG_TIME_FMT, tmp, (now.tv_usec / 1000));
|
||||
return current_time;
|
||||
}
|
||||
|
||||
@ -151,6 +157,7 @@ class S3fsLog
|
||||
static bool ReopenLogfile();
|
||||
static s3fs_log_level SetLogLevel(s3fs_log_level level);
|
||||
static s3fs_log_level BumpupLogLevel();
|
||||
static bool SetTimeStamp(bool value);
|
||||
|
||||
explicit S3fsLog();
|
||||
~S3fsLog();
|
||||
@ -164,7 +171,7 @@ class S3fsLog
|
||||
if(S3fsLog::IsS3fsLogLevel(level)){ \
|
||||
if(foreground || S3fsLog::IsSetLogFile()){ \
|
||||
S3fsLog::SeekEnd(); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s %s%s:%s(%d): " fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(level), __FILE__, __func__, __LINE__, __VA_ARGS__); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s%s%s:%s(%d): " fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(level), __FILE__, __func__, __LINE__, __VA_ARGS__); \
|
||||
S3fsLog::Flush(); \
|
||||
}else{ \
|
||||
syslog(S3fsLog::GetSyslogLevel(level), "%s%s:%s(%d): " fmt "%s", instance_name.c_str(), __FILE__, __func__, __LINE__, __VA_ARGS__); \
|
||||
@ -177,7 +184,7 @@ class S3fsLog
|
||||
if(S3fsLog::IsS3fsLogLevel(level)){ \
|
||||
if(foreground || S3fsLog::IsSetLogFile()){ \
|
||||
S3fsLog::SeekEnd(); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s %s%s%s:%s(%d): " fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(level), S3fsLog::GetS3fsLogNest(nest), __FILE__, __func__, __LINE__, __VA_ARGS__); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s%s%s%s:%s(%d): " fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(level), S3fsLog::GetS3fsLogNest(nest), __FILE__, __func__, __LINE__, __VA_ARGS__); \
|
||||
S3fsLog::Flush(); \
|
||||
}else{ \
|
||||
syslog(S3fsLog::GetSyslogLevel(level), "%s%s" fmt "%s", instance_name.c_str(), S3fsLog::GetS3fsLogNest(nest), __VA_ARGS__); \
|
||||
@ -189,7 +196,7 @@ class S3fsLog
|
||||
do{ \
|
||||
if(foreground || S3fsLog::IsSetLogFile()){ \
|
||||
S3fsLog::SeekEnd(); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s [CURL DBG] " fmt "%s\n", S3fsLog::GetCurrentTime(), __VA_ARGS__); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s[CURL DBG] " fmt "%s\n", S3fsLog::GetCurrentTime(), __VA_ARGS__); \
|
||||
S3fsLog::Flush(); \
|
||||
}else{ \
|
||||
syslog(S3fsLog::GetSyslogLevel(S3fsLog::LEVEL_CRIT), "%s" fmt "%s", instance_name.c_str(), __VA_ARGS__); \
|
||||
@ -213,7 +220,7 @@ class S3fsLog
|
||||
do{ \
|
||||
if(foreground || S3fsLog::IsSetLogFile()){ \
|
||||
S3fsLog::SeekEnd(); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s %s%s%s:%s(%d): " fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(S3fsLog::LEVEL_INFO), S3fsLog::GetS3fsLogNest(0), __FILE__, __func__, __LINE__, __VA_ARGS__, ""); \
|
||||
fprintf(S3fsLog::GetOutputLogFile(), "%s%s%s%s:%s(%d): " fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(S3fsLog::LEVEL_INFO), S3fsLog::GetS3fsLogNest(0), __FILE__, __func__, __LINE__, __VA_ARGS__, ""); \
|
||||
S3fsLog::Flush(); \
|
||||
}else{ \
|
||||
syslog(S3fsLog::GetSyslogLevel(S3fsLog::LEVEL_INFO), "%s%s" fmt "%s", instance_name.c_str(), S3fsLog::GetS3fsLogNest(0), __VA_ARGS__, ""); \
|
||||
|
||||
@ -257,6 +257,7 @@ function start_s3fs {
|
||||
-o stat_cache_expire=1 \
|
||||
-o stat_cache_interval_expire=1 \
|
||||
-o dbglevel=${DBGLEVEL:=info} \
|
||||
-o no_time_stamp_msg \
|
||||
-o retries=3 \
|
||||
-f \
|
||||
"${@}" &
|
||||
|
||||
Reference in New Issue
Block a user