<s> import time <EOL> import os <EOL> import sys <EOL> class Log : <EOL> def __init__ ( self , output = sys . stdout ) : <EOL> self . output = output <EOL> def __call__ ( self , f ) : <EOL> def func ( environ , start_response ) : <EOL> res = f ( environ , start_response ) <EOL> tts = time . strftime ( "<STR_LIT>" , time . gmtime ( ) ) <EOL> if type ( res ) is list : <EOL> content = "<STR_LIT>" . join ( res ) <EOL> size = len ( content ) <EOL> elif hasattr ( res , "<STR_LIT:name>" ) : <EOL> size = os . path . getsize ( res . name ) <EOL> else : <EOL> size = "<STR_LIT:->" <EOL> remote_host = environ . get ( '<STR_LIT>' , environ [ '<STR_LIT>' ] ) <EOL> self . output . write ( "<STR_LIT>" % ( remote_host , environ [ '<STR_LIT>' ] , tts , environ [ '<STR_LIT>' ] , environ [ '<STR_LIT>' ] , environ [ '<STR_LIT>' ] , start_response . status_code , size , environ . get ( "<STR_LIT>" , "<STR_LIT:->" ) , environ . get ( '<STR_LIT>' , "<STR_LIT:->" ) ) ) <EOL> self . output . flush ( ) <EOL> return res <EOL> return func </s>
