diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 9f66200..ff87965 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -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()){ diff --git a/src/s3fs_help.cpp b/src/s3fs_help.cpp index d8fdbaf..b45190c 100644 --- a/src/s3fs_help.cpp +++ b/src/s3fs_help.cpp @@ -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 diff --git a/src/s3fs_help.h b/src/s3fs_help.h index 8b80cde..04ce416 100644 --- a/src/s3fs_help.h +++ b/src/s3fs_help.h @@ -27,6 +27,7 @@ void show_usage(); void show_help(); void show_version(); +const char* short_version(); #endif // S3FS_S3FS_HELP_H_ diff --git a/src/s3fs_logger.h b/src/s3fs_logger.h index dac5aba..38d5f7d 100644 --- a/src/s3fs_logger.h +++ b/src/s3fs_logger.h @@ -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{ \ diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index b07f158..9c30d5c 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -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 diff --git a/src/s3fs_util.h b/src/s3fs_util.h index e8537f7..01d46b6 100644 --- a/src/s3fs_util.h +++ b/src/s3fs_util.h @@ -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_ /*