Browse Source

Updated ee log command

bugfixes
gau1991 10 years ago
parent
commit
e94f20f722
  1. 78
      ee/cli/plugins/log.py

78
ee/cli/plugins/log.py

@ -5,6 +5,8 @@ from cement.core import handler, hook
from ee.core.logging import Log
from ee.cli.plugins.site_functions import logwatch
from ee.core.variables import EEVariables
from ee.core.fileutils import EEFileUtils
from ee.core.shellexec import EEShellExec
import os
import glob
@ -24,11 +26,22 @@ class EELogController(CementBaseController):
(['--all'],
dict(help='Show All logs file', action='store_true')),
(['--nginx'],
dict(help='Show Nginx logs file', action='store_true')),
dict(help='Show Nginx Error logs file', action='store_true')),
(['--php'],
dict(help='Show PHP logs file', action='store_true')),
dict(help='Show PHP Error logs file', action='store_true')),
(['--fpm'],
dict(help='Show PHP5-fpm slow logs file',
action='store_true')),
(['--mysql'],
dict(help='Show MySQL logs file', action='store_true')),
(['--wp'],
dict(help='Show Site specific WordPress logs file',
action='store_true')),
(['--access'],
dict(help='Show Nginx access log file',
action='store_true')),
(['site_name'],
dict(help='Website Name', nargs='?', default=None))
]
@expose(hide=True)
@ -36,15 +49,32 @@ class EELogController(CementBaseController):
"""Default function of debug"""
self.msg = []
if ((not self.app.pargs.nginx) and (not self.app.pargs.php)
and (not self.app.pargs.mysql)):
if self.app.pargs.php:
self.app.pargs.nginx = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (not self.app.pargs.site_name)):
self.app.pargs.nginx = True
self.app.pargs.fpm = True
self.app.pargs.mysql = True
self.app.pargs.access = True
if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm)
and (not self.app.pargs.mysql) and (not self.app.pargs.access)
and (not self.app.pargs.wp) and (self.app.pargs.site_name)):
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.wp = True
self.app.pargs.access = True
self.app.pargs.mysql = True
if self.app.pargs.nginx:
if self.app.pargs.nginx and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*error.log"]
if self.app.pargs.php:
if self.app.pargs.access and (not self.app.pargs.site_name):
self.msg = self.msg + ["/var/log/nginx/*access.log"]
if self.app.pargs.fpm:
open('/var/log/php5/slow.log', 'a').close()
open('/var/log/php5/fpm.log', 'a').close()
self.msg = self.msg + ['/var/log/php5/slow.log',
@ -62,6 +92,40 @@ class EELogController(CementBaseController):
Log.warn(self, "Remote MySQL found, EasyEngine is not able to"
"show MySQL log file")
if self.app.pargs.site_name:
if self.app.pargs.access:
self.msg = self.msg + ["{0}/{1}/logs/access.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.nginx:
self.msg = self.msg + ["{0}/{1}/logs/error.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
if self.app.pargs.wp:
webroot = "{0}{1}".format(EEVariables.ee_webroot,
self.app.pargs.site_name)
if not os.path.isfile('{0}/logs/debug.log'
.format(webroot)):
if not os.path.isfile('{0}/htdocs/wp-content/debug.log'
.format(webroot)):
open("{0}/htdocs/wp-content/debug.log".format(webroot),
encoding='utf-8', mode='a').close()
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
"content/debug.log"
"".format(webroot,
EEVariables.ee_php_user)
)
# create symbolic link for debug log
EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/"
"debug.log"
.format(webroot),
'{0}/logs/debug.log'
.format(webroot)])
self.msg = self.msg + ["{0}/{1}/logs/debug.log"
.format(EEVariables.ee_webroot,
self.app.pargs.site_name)]
watch_list = []
for w_list in self.msg:
watch_list = watch_list + glob.glob(w_list)

Loading…
Cancel
Save