(self)
Write to the access log (in Apache/NCSA Combined Log format).

        See the
        `apache documentation
        <http://httpd.apache.org/docs/current/logs.html#combined>`_
        for format details.

        CherryPy calls this automatically for you. Note there are no arguments;
        it collects the data itself from
        :class:`cherrypy.request<cherrypy._cprequest.Request>`.

        Like Apache started doing in 2.0.46, non-printable and other special
        characters in %r (and we expand that to all parts) are escaped using
        \\xhh sequences, where hh stands for the hexadecimal representation
        of the raw byte. Exceptions from this rule are " and \\, which are
        escaped by prepending a backslash, and all whitespace characters,
        which are written in their C-style notation (\\n, \\t, etc).
Write to the access log (in Apache/NCSA Combined Log format).
Write to the access log ( in Apache / NCSA Combined Log format ) .
def access(self):
        """Write to the access log (in Apache/NCSA Combined Log format).

        See the
        `apache documentation
        <http://httpd.apache.org/docs/current/logs.html#combined>`_
        for format details.

        CherryPy calls this automatically for you. Note there are no arguments;
        it collects the data itself from
        :class:`cherrypy.request<cherrypy._cprequest.Request>`.

        Like Apache started doing in 2.0.46, non-printable and other special
        characters in %r (and we expand that to all parts) are escaped using
        \\xhh sequences, where hh stands for the hexadecimal representation
        of the raw byte. Exceptions from this rule are " and \\, which are
        escaped by prepending a backslash, and all whitespace characters,
        which are written in their C-style notation (\\n, \\t, etc).
        """
        request = cherrypy.serving.request
        remote = request.remote
        response = cherrypy.serving.response
        outheaders = response.headers
        inheaders = request.headers
        if response.output_status is None:
            status = '-'
        else:
            status = response.output_status.split(b' ', 1)[0]
            status = status.decode('ISO-8859-1')

        atoms = {'h': remote.name or remote.ip,
                 'l': '-',
                 'u': getattr(request, 'login', None) or '-',
                 't': self.time(),
                 'r': request.request_line,
                 's': status,
                 'b': dict.get(outheaders, 'Content-Length', '') or '-',
                 'f': dict.get(inheaders, 'Referer', ''),
                 'a': dict.get(inheaders, 'User-Agent', ''),
                 'o': dict.get(inheaders, 'Host', '-'),
                 'i': request.unique_id,
                 'z': LazyRfc3339UtcTime(),
                 }
        for k, v in atoms.items():
            if not isinstance(v, str):
                v = str(v)
            v = v.replace('"', '\\"').encode('utf8')
            # Fortunately, repr(str) escapes unprintable chars, \n, \t, etc
            # and backslash for us. All we have to do is strip the quotes.
            v = repr(v)[2:-1]

            # in python 3.0 the repr of bytes (as returned by encode)
            # uses double \'s.  But then the logger escapes them yet, again
            # resulting in quadruple slashes.  Remove the extra one here.
            v = v.replace('\\\\', '\\')

            # Escape double-quote.
            atoms[k] = v

        try:
            self.access_log.log(
                logging.INFO, self.access_log_format.format(**atoms))
        except Exception:
            self(traceback=True)
def access ( self ) : request = cherrypy . serving . request remote = request . remote response = cherrypy . serving . response outheaders = response . headers inheaders = request . headers if response . output_status is None : status = '-' else : status = response . output_status . split ( b' ' , 1 ) [ 0 ] status = status . decode ( 'ISO-8859-1' ) atoms = { 'h' : remote . name or remote . ip , 'l' : '-' , 'u' : getattr ( request , 'login' , None ) or '-' , 't' : self . time ( ) , 'r' : request . request_line , 's' : status , 'b' : dict . get ( outheaders , 'Content-Length' , '' ) or '-' , 'f' : dict . get ( inheaders , 'Referer' , '' ) , 'a' : dict . get ( inheaders , 'User-Agent' , '' ) , 'o' : dict . get ( inheaders , 'Host' , '-' ) , 'i' : request . unique_id , 'z' : LazyRfc3339UtcTime ( ) , } for k , v in atoms . items ( ) : if not isinstance ( v , str ) : v = str ( v ) v = v . replace ( '"' , '\\"' ) . encode ( 'utf8' ) # Fortunately, repr(str) escapes unprintable chars, \n, \t, etc # and backslash for us. All we have to do is strip the quotes. v = repr ( v ) [ 2 : - 1 ] # in python 3.0 the repr of bytes (as returned by encode) # uses double \'s.  But then the logger escapes them yet, again # resulting in quadruple slashes.  Remove the extra one here. v = v . replace ( '\\\\' , '\\' ) # Escape double-quote. atoms [ k ] = v try : self . access_log . log ( logging . INFO , self . access_log_format . format ( * * atoms ) ) except Exception : self ( traceback = True )