mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
Move logfile functionality to the REPL as intended
This commit is contained in:
@@ -73,7 +73,6 @@ class ConsoleApplication(object):
|
||||
action='store_const', const='remote', dest="device_type", default=None)
|
||||
parser.add_option("-H", "--host", help="connect to remote frida-server on HOST",
|
||||
metavar="HOST", type='string', action='store', dest="host", default=None)
|
||||
parser.add_option("-o", "--output", help="output to log file", dest="logfile", default=None)
|
||||
if self._needs_target():
|
||||
def store_target(option, opt_str, target_value, parser, target_type, *args, **kwargs):
|
||||
if target_type == 'file':
|
||||
@@ -120,13 +119,6 @@ class ConsoleApplication(object):
|
||||
self._exit_status = None
|
||||
self._console_state = ConsoleState.EMPTY
|
||||
self._quiet = False
|
||||
self._logfile = None;
|
||||
if options.logfile is not None:
|
||||
try:
|
||||
self._logfile = open(options.logfile, 'w')
|
||||
except Exception as e:
|
||||
self._update_status('Failed to open logfile "%s"' % options.logfile)
|
||||
sys.exit(1)
|
||||
if sum(map(lambda v: int(v is not None), (self._device_id, self._device_type, self._host))) > 1:
|
||||
parser.error("Only one of -D, -U, -R, and -H may be specified")
|
||||
|
||||
@@ -317,8 +309,6 @@ class ConsoleApplication(object):
|
||||
else:
|
||||
color = Fore.RED if level == 'error' else Fore.YELLOW
|
||||
self._print(color + Style.BRIGHT + text + Style.RESET_ALL)
|
||||
if self._logfile is not None:
|
||||
self._logfile.write(text + "\n");
|
||||
|
||||
def find_device(type):
|
||||
for device in frida.enumerate_devices():
|
||||
|
||||
@@ -43,12 +43,26 @@ def main():
|
||||
action='store_true', dest="quiet", default=False)
|
||||
parser.add_option("--no-pause", help="automatically start main thread after startup",
|
||||
action='store_true', dest="no_pause", default=False)
|
||||
parser.add_option("-o", "--output", help="output to log file", dest="logfile", default=None)
|
||||
|
||||
def _initialize(self, parser, options, args):
|
||||
self._user_script = options.user_script
|
||||
self._pending_eval = options.eval_items
|
||||
self._quiet = options.quiet
|
||||
self._no_pause = options.no_pause
|
||||
if options.logfile is not None:
|
||||
try:
|
||||
self._logfile = open(options.logfile, 'w')
|
||||
except Exception as e:
|
||||
self._update_status('Failed to open logfile "%s"' % options.logfile)
|
||||
self._exit(1)
|
||||
else:
|
||||
self._logfile = None
|
||||
|
||||
def _log(self, level, text):
|
||||
ConsoleApplication._log(self, level, text)
|
||||
if self._logfile is not None:
|
||||
self._logfile.write(text + "\n")
|
||||
|
||||
def _usage(self):
|
||||
return "usage: %prog [options] target"
|
||||
|
||||
Reference in New Issue
Block a user