Revonzy Mini Shell

Şuanki Dizin: /lib/python2.7/site-packages/boto/
Dosya Yükle :
Şuanki Dosya : //lib/python2.7/site-packages/boto/requestlog.py

import sys
from datetime import datetime
from threading import Thread
import Queue

from boto.utils import RequestHook
from boto.compat import long_type


class RequestLogger(RequestHook):
    """
    This class implements a request logger that uses a single thread to
    write to a log file.
    """
    def __init__(self, filename='/tmp/request_log.csv'):
        self.request_log_file = open(filename, 'w')
        self.request_log_queue = Queue.Queue(100)
        Thread(target=self._request_log_worker).start()

    def handle_request_data(self, request, response, error=False):
        len = 0 if error else response.getheader('Content-Length')
        now = datetime.now()
        time = now.strftime('%Y-%m-%d %H:%M:%S')
        td = (now - request.start_time)
        duration = (td.microseconds + long_type(td.seconds + td.days * 24 * 3600) * 1e6) / 1e6

        # write output including timestamp, status code, response time, response size, request action
        self.request_log_queue.put("'%s', '%s', '%s', '%s', '%s'\n" % (time, response.status, duration, len, request.params.get('Action')))

    def _request_log_worker(self):
        while True:
            try:
                item = self.request_log_queue.get(True)
                self.request_log_file.write(item)
                self.request_log_file.flush()
                self.request_log_queue.task_done()
            except:
                import traceback
                traceback.print_exc(file=sys.stdout)

EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com

Linux vps.suncrosonline.com 3.10.0-862.3.2.el7.x86_64 #1 SMP Mon May 21 23:36:36 UTC 2018 x86_64
Apache
162.241.69.42