-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log format #704
Log format #704
Changes from 5 commits
8cf02c7
a3c2b89
5893410
acb315a
442f779
59463bd
f5974a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,6 +202,7 @@ start_seaf_server () | |
"-l", logfile, | ||
"-P", ctl->pidfile[PID_SERVER], | ||
"-p", ctl->rpc_pipe_path, | ||
"-f", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. controller 和 seaf-server 应该在检测到 SEAFILE_LOG_TO_STDOUT 这个环境变量之后,主动禁用 daemon mode。这里不应该直接禁用 daemon mode,因为会影响非 docker 部署的用户。docker 部署下,应该是不需要 daemon mode 的,因为容器会一直运行。 |
||
NULL}; | ||
|
||
int pid = spawn_process (argv, false); | ||
|
@@ -568,8 +569,8 @@ seaf_controller_init (SeafileController *ctl, | |
char *topdir = g_path_get_dirname(config_dir); | ||
logdir = g_build_filename (topdir, "logs", NULL); | ||
if (checkdir_with_mkdir(logdir) < 0) { | ||
fprintf (stderr, "failed to create log folder \"%s\": %s\n", | ||
logdir, strerror(errno)); | ||
seaf_error ("failed to create log folder \"%s\": %s\n", | ||
logdir, strerror(errno)); | ||
return -1; | ||
} | ||
g_free (topdir); | ||
|
@@ -683,12 +684,13 @@ set_signal_handlers () | |
static void | ||
usage () | ||
{ | ||
fprintf (stderr, "Usage: seafile-controller OPTIONS\n" | ||
"OPTIONS:\n" | ||
" -b, --bin-dir insert a directory in front of the PATH env\n" | ||
" -c, --config-dir ccnet config dir\n" | ||
" -d, --seafile-dir seafile dir\n" | ||
); | ||
seafile_log_init ("-", "debug", "debug"); | ||
seaf_error ("Usage: seafile-controller OPTIONS\n" | ||
"OPTIONS:\n" | ||
" -b, --bin-dir insert a directory in front of the PATH env\n" | ||
" -c, --config-dir ccnet config dir\n" | ||
" -d, --seafile-dir seafile dir\n" | ||
); | ||
} | ||
|
||
/* seafile-controller -t is used to test whether config file is valid */ | ||
|
@@ -717,9 +719,8 @@ test_config (const char *central_config_dir, | |
&error); | ||
|
||
if (error != NULL) { | ||
fprintf (stderr, | ||
"failed to run \"seaf-server -t\": %s\n", | ||
error->message); | ||
seaf_error ("failed to run \"seaf-server -t\": %s\n", | ||
error->message); | ||
exit (1); | ||
} | ||
|
||
|
@@ -732,8 +733,7 @@ test_config (const char *central_config_dir, | |
} | ||
|
||
if (retcode != 0) { | ||
fprintf (stderr, | ||
"failed to run \"seaf-server -t\" [%d]\n", retcode); | ||
seaf_error ("failed to run \"seaf-server -t\" [%d]\n", retcode); | ||
exit (1); | ||
} | ||
|
||
|
@@ -869,7 +869,9 @@ int main (int argc, char **argv) | |
exit(1); | ||
break; | ||
case 'v': | ||
fprintf (stderr, "seafile-controller version 1.0\n"); | ||
seafile_log_init ("-", "debug", "debug"); | ||
seaf_message ("seafile-controller version 1.0\n"); | ||
exit(1); | ||
break; | ||
case 't': | ||
test_conf = TRUE; | ||
|
@@ -911,13 +913,21 @@ int main (int argc, char **argv) | |
g_thread_init (NULL); | ||
#endif | ||
|
||
char *logfile = g_build_filename (ctl->logdir, "controller.log", NULL); | ||
if (seafile_log_init (logfile, ccnet_debug_level_str, | ||
seafile_debug_level_str) < 0) { | ||
seafile_log_init ("-", ccnet_debug_level_str, seafile_debug_level_str); | ||
seaf_error ("Failed to init log.\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在 seafile_log_init 之前的日志,就用 printf 输出就行了,这些都是些参数错误,在生产环境是不会出现的,所以不重要。其他几个组件也不需要改这些日志的输出了。 |
||
controller_exit (1); | ||
} | ||
|
||
if (!seafile_dir) { | ||
fprintf (stderr, "<seafile_dir> must be specified with --seafile-dir\n"); | ||
seaf_error ("<seafile_dir> must be specified with --seafile-dir\n"); | ||
exit(1); | ||
} | ||
|
||
if (!central_config_dir) { | ||
fprintf (stderr, "<central_config_dir> must be specified with --central-config-dir\n"); | ||
seaf_error ("<central_config_dir> must be specified with --central-config-dir\n"); | ||
exit(1); | ||
} | ||
|
||
|
@@ -934,13 +944,6 @@ int main (int argc, char **argv) | |
controller_exit(1); | ||
} | ||
|
||
char *logfile = g_build_filename (ctl->logdir, "controller.log", NULL); | ||
if (seafile_log_init (logfile, ccnet_debug_level_str, | ||
seafile_debug_level_str) < 0) { | ||
seaf_warning ("Failed to init log.\n"); | ||
controller_exit (1); | ||
} | ||
|
||
if (init_syslog_config () < 0) { | ||
controller_exit (1); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,14 +31,14 @@ static const struct option long_opts[] = { | |
|
||
static void usage () | ||
{ | ||
fprintf (stderr, | ||
"usage: seafserv-gc [-c config_dir] [-d seafile_dir] " | ||
"[repo_id_1 [repo_id_2 ...]]\n" | ||
"Additional options:\n" | ||
"-r, --rm-deleted: remove garbaged repos\n" | ||
"-R, --rm-fs: remove fs object\n" | ||
"-D, --dry-run: report blocks that can be remove, but not remove them\n" | ||
"-V, --verbose: verbose output messages\n"); | ||
seafile_log_init ("-", "info", "debug"); | ||
seaf_error ("usage: seafserv-gc [-c config_dir] [-d seafile_dir] " | ||
"[repo_id_1 [repo_id_2 ...]]\n" | ||
"Additional options:\n" | ||
"-r, --rm-deleted: remove garbaged repos\n" | ||
"-R, --rm-fs: remove fs object\n" | ||
"-D, --dry-run: report blocks that can be remove, but not remove them\n" | ||
"-V, --verbose: verbose output messages\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gc 和 fsck 的 usage 日志不用改了。 |
||
} | ||
|
||
#ifdef WIN32 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该在 seafile_log_init 函数增加一个参数(第一个参数),用于指定组件的名称,因为需要区分 seaf-server, seaf-fuse, controller 三个组件的日志的。还有 slow log 也有自己的日志名称。