'Constructor.
Args:
rpcserver: The RPC server to use.  Should be an instance of HttpRpcServer
or TestRpcServer.
app_id: The application to fetch logs from.
module: The module of the app to fetch logs from, optional.
version_id: The version of the app to fetch logs for.
output_file: Output file name.
num_days: Number of days worth of logs to export; 0 for all available.
append: True if appending to an existing file.
severity: App log severity to request (0-4); None for no app logs.
end: date object representing last day of logs to return.
vhost: The virtual host of log messages to get. None for all hosts.
include_vhost: If true, the virtual host is included in log messages.
include_all: If true, we add to the log message everything we know
about the request.
time_func: A time.time() compatible function, which can be overridden for
testing.
error_fh: Where to send status and error messages.'

def __init__(self, rpcserver, app_id, module, version_id, output_file, num_days, append, severity, end, vhost, include_vhost, include_all=None, time_func=time.time, error_fh=sys.stderr):

    self.rpcserver = rpcserver
    self.app_id = app_id
    self.output_file = output_file
    self.append = append
    self.num_days = num_days
    self.severity = severity
    self.vhost = vhost
    self.include_vhost = include_vhost
    self.include_all = include_all
    self.error_fh = error_fh
    self.module = module
    self.version_id = version_id
    self.sentinel = None
    self.write_mode = 'w'
    if self.append:
        self.sentinel = FindSentinel(self.output_file)
        self.write_mode = 'a'
    self.skip_until = False
    now = PacificDate(time_func())
    if (end < now):
        self.skip_until = end
    else:
        end = now
    self.valid_dates = None
    if self.num_days:
        start = (end - datetime.timedelta((self.num_days - 1)))
        self.valid_dates = (start, end)
