Output version and command parameters at startup

This commit is contained in:
Takeshi Nakatani 2021-03-06 03:04:14 +00:00 committed by Andrew Gaul
parent 8c58ba8ac0
commit b589ebec23
6 changed files with 46 additions and 0 deletions

View File

@ -4888,6 +4888,8 @@ int main(int argc, char* argv[])
exit(EXIT_FAILURE);
}
}
// print launch message
print_launch_message(argc, argv);
// Load SSE environment
if(!S3fsCurl::LoadEnvSse()){

View File

@ -558,6 +558,12 @@ void show_version()
VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name());
}
const char* short_version()
{
static const char short_ver[] = "s3fs version " VERSION "(" COMMIT_HASH_VAL ")";
return short_ver;
}
/*
* Local variables:
* tab-width: 4

View File

@ -27,6 +27,7 @@
void show_usage();
void show_help();
void show_version();
const char* short_version();
#endif // S3FS_S3FS_HELP_H_

View File

@ -227,6 +227,17 @@ class S3fsLog
} \
}while(0)
#define S3FS_PRN_LAUNCH_INFO(fmt, ...) \
do{ \
if(foreground || S3fsLog::IsSetLogFile()){ \
S3fsLog::SeekEnd(); \
fprintf(S3fsLog::GetOutputLogFile(), "%s%s" fmt "%s\n", S3fsLog::GetCurrentTime(), S3fsLog::GetLevelString(S3fsLog::LEVEL_INFO), __VA_ARGS__, ""); \
S3fsLog::Flush(); \
}else{ \
syslog(S3fsLog::GetSyslogLevel(S3fsLog::LEVEL_INFO), "%s" fmt "%s", instance_name.c_str(), __VA_ARGS__, ""); \
} \
}while(0)
// Special macro for checking cache files
#define S3FS_LOW_CACHE(fp, fmt, ...) \
do{ \

View File

@ -36,6 +36,7 @@
#include "s3fs.h"
#include "s3fs_util.h"
#include "string_util.h"
#include "s3fs_help.h"
//-------------------------------------------------------------------
// Global variables
@ -368,6 +369,29 @@ bool compare_sysname(const char* target)
return true;
}
//-------------------------------------------------------------------
// Utility for print message at launching
//-------------------------------------------------------------------
void print_launch_message(int argc, char** argv)
{
std::string message = short_version();
if(argv){
message += " :";
for(int cnt = 0; cnt < argc; ++cnt){
if(argv[cnt]){
message += " ";
if(0 == cnt){
message += basename(argv[cnt]);
}else{
message += argv[cnt];
}
}
}
}
S3FS_PRN_LAUNCH_INFO("%s", message.c_str());
}
/*
* Local variables:
* tab-width: 4

View File

@ -42,6 +42,8 @@ bool delete_files_in_dir(const char* dir, bool is_remove_own);
bool compare_sysname(const char* target);
void print_launch_message(int argc, char** argv);
#endif // S3FS_S3FS_UTIL_H_
/*