#NEWLINE# def callback( self , filename , lines , **kwargs ) : #NEWLINE# #INDENT# timestamp = self . get_timestamp ( ** kwargs ) #NEWLINE# if kwargs . get ( 'timestamp' , False ) : #NEWLINE# #INDENT# del kwargs [ 'timestamp' ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# for line in lines : #NEWLINE# #INDENT# jsonline = self . format ( filename , line , timestamp , ** kwargs ) #NEWLINE# edata = jsonline . replace ( '\t' , '\\t' ) #NEWLINE# self . _logger . debug ( 'writing to : {0}' . format ( self . _url ) ) #NEWLINE# self . _logger . debug ( 'writing data: {0}' . format ( edata ) ) #NEWLINE# r = requests . post ( url = self . _url , data = edata ) #NEWLINE# if ( ( r . status_code >= 200 ) and ( r . status_code < 300 ) ) : #NEWLINE# #INDENT# res = r . content #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _logger . error ( 'Post returned non 2xx http status: {0}/{1}' . format ( r . status_code , r . reason ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . _logger . error ( ( 'Exception caught in urlopen connection: ' + str ( e ) ) )