add an instance_name option for logging

This commit is contained in:
Or Ozeri 2018-02-28 09:51:35 +02:00
parent e1dafe76dd
commit b52b6f3fc5
5 changed files with 19 additions and 4 deletions

View File

@ -256,6 +256,10 @@ Customize TLS cipher suite list. Expects a colon separated list of cipher suite
A list of available cipher suites, depending on your TLS engine, can be found on the CURL library documentation: A list of available cipher suites, depending on your TLS engine, can be found on the CURL library documentation:
https://curl.haxx.se/docs/ssl-ciphers.html https://curl.haxx.se/docs/ssl-ciphers.html
.TP .TP
\fB\-o\fR instance_name
The instance name of the current s3fs mountpoint.
This name will be added to logging messages and user agent headers sent by s3fs.
.TP
\fB\-o\fR complement_stat (complement lack of file/directory mode) \fB\-o\fR complement_stat (complement lack of file/directory mode)
s3fs complements lack of information about file/directory mode if a file or a directory object does not have x-amz-meta-mode header. s3fs complements lack of information about file/directory mode if a file or a directory object does not have x-amz-meta-mode header.
As default, s3fs does not complements stat information for a object, then the object will not be able to be allowed to list/modify. As default, s3fs does not complements stat information for a object, then the object will not be able to be allowed to list/modify.

View File

@ -79,7 +79,7 @@ enum s3fs_log_level{
if(foreground){ \ if(foreground){ \
fprintf(stdout, "%s%s:%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(level), __FILE__, __func__, __LINE__, __VA_ARGS__); \ fprintf(stdout, "%s%s:%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(level), __FILE__, __func__, __LINE__, __VA_ARGS__); \
}else{ \ }else{ \
syslog(S3FS_LOG_LEVEL_TO_SYSLOG(level), "%s:%s(%d): " fmt "%s", __FILE__, __func__, __LINE__, __VA_ARGS__); \ syslog(S3FS_LOG_LEVEL_TO_SYSLOG(level), "%s%s:%s(%d): " fmt "%s", instance_name.c_str(), __FILE__, __func__, __LINE__, __VA_ARGS__); \
} \ } \
} }
@ -88,7 +88,7 @@ enum s3fs_log_level{
if(foreground){ \ if(foreground){ \
fprintf(stdout, "%s%s%s:%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(level), S3FS_LOG_NEST(nest), __FILE__, __func__, __LINE__, __VA_ARGS__); \ fprintf(stdout, "%s%s%s:%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(level), S3FS_LOG_NEST(nest), __FILE__, __func__, __LINE__, __VA_ARGS__); \
}else{ \ }else{ \
syslog(S3FS_LOG_LEVEL_TO_SYSLOG(level), "%s" fmt "%s", S3FS_LOG_NEST(nest), __VA_ARGS__); \ syslog(S3FS_LOG_LEVEL_TO_SYSLOG(level), "%s%s" fmt "%s", instance_name.c_str(), S3FS_LOG_NEST(nest), __VA_ARGS__); \
} \ } \
} }
@ -97,7 +97,7 @@ enum s3fs_log_level{
fprintf(stderr, "s3fs: " fmt "%s\n", __VA_ARGS__); \ fprintf(stderr, "s3fs: " fmt "%s\n", __VA_ARGS__); \
}else{ \ }else{ \
fprintf(stderr, "s3fs: " fmt "%s\n", __VA_ARGS__); \ fprintf(stderr, "s3fs: " fmt "%s\n", __VA_ARGS__); \
syslog(S3FS_LOG_LEVEL_TO_SYSLOG(S3FS_LOG_CRIT), "s3fs: " fmt "%s", __VA_ARGS__); \ syslog(S3FS_LOG_LEVEL_TO_SYSLOG(S3FS_LOG_CRIT), "%ss3fs: " fmt "%s", instance_name.c_str(), __VA_ARGS__); \
} }
// Special macro for init message // Special macro for init message
@ -105,7 +105,7 @@ enum s3fs_log_level{
if(foreground){ \ if(foreground){ \
fprintf(stdout, "%s%s%s:%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(S3FS_LOG_INFO), S3FS_LOG_NEST(0), __FILE__, __func__, __LINE__, __VA_ARGS__, ""); \ fprintf(stdout, "%s%s%s:%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(S3FS_LOG_INFO), S3FS_LOG_NEST(0), __FILE__, __func__, __LINE__, __VA_ARGS__, ""); \
}else{ \ }else{ \
syslog(S3FS_LOG_LEVEL_TO_SYSLOG(S3FS_LOG_INFO), "%s" fmt "%s", S3FS_LOG_NEST(0), __VA_ARGS__, ""); \ syslog(S3FS_LOG_LEVEL_TO_SYSLOG(S3FS_LOG_INFO), "%s%s" fmt "%s", instance_name.c_str(), S3FS_LOG_NEST(0), __VA_ARGS__, ""); \
} }
// [NOTE] // [NOTE]
@ -168,6 +168,7 @@ extern std::string bucket;
extern std::string mount_prefix; extern std::string mount_prefix;
extern std::string endpoint; extern std::string endpoint;
extern std::string cipher_suites; extern std::string cipher_suites;
extern std::string instance_name;
extern s3fs_log_level debug_level; extern s3fs_log_level debug_level;
extern const char* s3fs_log_nest[S3FS_LOG_NEST_MAX]; extern const char* s3fs_log_nest[S3FS_LOG_NEST_MAX];

View File

@ -631,6 +631,7 @@ void S3fsCurl::InitUserAgent(void)
S3fsCurl::userAgent += "; "; S3fsCurl::userAgent += "; ";
S3fsCurl::userAgent += s3fs_crypt_lib_name(); S3fsCurl::userAgent += s3fs_crypt_lib_name();
S3fsCurl::userAgent += ")"; S3fsCurl::userAgent += ")";
S3fsCurl::userAgent += instance_name;
} }
} }

View File

@ -100,6 +100,7 @@ std::string host = "https://s3.amazonaws.com";
std::string bucket = ""; std::string bucket = "";
std::string endpoint = "us-east-1"; std::string endpoint = "us-east-1";
std::string cipher_suites = ""; std::string cipher_suites = "";
std::string instance_name = "";
s3fs_log_level debug_level = S3FS_LOG_CRIT; s3fs_log_level debug_level = S3FS_LOG_CRIT;
const char* s3fs_log_nest[S3FS_LOG_NEST_MAX] = {"", " ", " ", " "}; const char* s3fs_log_nest[S3FS_LOG_NEST_MAX] = {"", " ", " ", " "};
@ -4777,6 +4778,11 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
cipher_suites = strchr(arg, '=') + sizeof(char); cipher_suites = strchr(arg, '=') + sizeof(char);
return 0; return 0;
} }
if(0 == STR2NCMP(arg, "instance_name=")){
instance_name = strchr(arg, '=') + sizeof(char);
instance_name = "[" + instance_name + "]";
return 0;
}
// //
// debug option for s3fs // debug option for s3fs
// //

View File

@ -1240,6 +1240,9 @@ void show_help (void)
" can be found on the CURL library documentation:\n" " can be found on the CURL library documentation:\n"
" https://curl.haxx.se/docs/ssl-ciphers.html\n" " https://curl.haxx.se/docs/ssl-ciphers.html\n"
"\n" "\n"
" instance_name - The instance name of the current s3fs mountpoint.\n"
" This name will be added to logging messages and user agent headers sent by s3fs.\n"
"\n"
" complement_stat (complement lack of file/directory mode)\n" " complement_stat (complement lack of file/directory mode)\n"
" s3fs complements lack of information about file/directory mode\n" " s3fs complements lack of information about file/directory mode\n"
" if a file or a directory object does not have x-amz-meta-mode\n" " if a file or a directory object does not have x-amz-meta-mode\n"