}
# TODO: load/save configs with database
+ # set log file
+ if ($app->config->{Log} && $app->config->{Log}->{system_log}) {
+ # check log is writable
+ my $pathname = $app->config->{Log}->{system_log};
+ if (-e $pathname) {
+ if (-w $pathname) {
+ $app->log->debug("logs will be outputed to $pathname ...");
+ $app->log(Mojo::Log->new);
+ $app->log->path($pathname);
+ }
+ else {
+ $app->log->error("cannot write system log to file: $pathname");
+ }
+ }
+ else {
+ if (open(my $fh, ">", $pathname)) {
+ close($fh);
+ $app->log->debug("logs will be outputed to $pathname ...");
+ $app->log(Mojo::Log->new);
+ $app->log->path($pathname);
+ }
+ else {
+ $app->log->error("cannot create system log file: $pathname");
+ }
+ }
+ }
+
# set log level
if ($app->config->{Log} && $app->config->{Log}->{level}) {
my $loglv = $app->config->{Log}->{level};