avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject avro git commit: AVRO-1874: Py3: Use recommended module-level logging.
Date Sun, 04 Sep 2016 21:37:28 GMT
Repository: avro
Updated Branches:
  refs/heads/master e6d2c4d86 -> 64f898c43


AVRO-1874: Py3: Use recommended module-level logging.

The previous use of the logging library, using logging as logger
handler, unsets logging level set by host application.

Closes #105.


Project: http://git-wip-us.apache.org/repos/asf/avro/repo
Commit: http://git-wip-us.apache.org/repos/asf/avro/commit/64f898c4
Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/64f898c4
Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/64f898c4

Branch: refs/heads/master
Commit: 64f898c4322ec641379c9916007303acfe817f84
Parents: e6d2c4d
Author: Torgeir Boerresen <torgeir.borresen@sigmagroup.no>
Authored: Tue Jul 5 10:28:23 2016 +0200
Committer: Ryan Blue <blue@apache.org>
Committed: Sun Sep 4 14:37:09 2016 -0700

----------------------------------------------------------------------
 CHANGES.txt               |  3 +++
 lang/py3/avro/datafile.py |  8 +++++---
 lang/py3/avro/io.py       |  3 ++-
 lang/py3/avro/ipc.py      | 20 +++++++++++---------
 lang/py3/avro/schema.py   |  3 ++-
 5 files changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/avro/blob/64f898c4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 70a2e33..4e28878 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -42,6 +42,9 @@ Trunk (not yet released)
     AVRO-1848: Ruby: Fix handling of falsey default values.
     (Brian McKelvey via blue)
 
+    AVRO-1874: Py3: Use recommended module-level logging.
+    (Torgeir Børresen via blue)
+
 Avro 1.8.1 (14 May 2016)
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/avro/blob/64f898c4/lang/py3/avro/datafile.py
----------------------------------------------------------------------
diff --git a/lang/py3/avro/datafile.py b/lang/py3/avro/datafile.py
index 7894d79..2a22e57 100644
--- a/lang/py3/avro/datafile.py
+++ b/lang/py3/avro/datafile.py
@@ -35,6 +35,8 @@ except ImportError:
   has_snappy = False
 
 
+logger = logging.getLogger(__name__)
+
 # ------------------------------------------------------------------------------
 # Constants
 
@@ -238,7 +240,7 @@ class DataFileWriter(object):
         'meta': self.meta,
         'sync': self.sync_marker,
     }
-    logging.debug(
+    logger.debug(
         'Writing Avro data file header:\n%s\nAvro header schema:\n%s',
         header, META_SCHEMA)
     self.datum_writer.write_data(META_SCHEMA, header, self.encoder)
@@ -250,7 +252,7 @@ class DataFileWriter(object):
       self._WriteHeader()
 
     if self.block_count <= 0:
-      logging.info('Current block is empty, nothing to write.')
+      logger.info('Current block is empty, nothing to write.')
       return
 
     # write number of items in block
@@ -287,7 +289,7 @@ class DataFileWriter(object):
     # write sync marker
     self.writer.write(self.sync_marker)
 
-    logging.debug(
+    logger.debug(
         'Writing block with count=%d nbytes=%d sync=%r',
         self.block_count, compressed_data_length, self.sync_marker)
 

http://git-wip-us.apache.org/repos/asf/avro/blob/64f898c4/lang/py3/avro/io.py
----------------------------------------------------------------------
diff --git a/lang/py3/avro/io.py b/lang/py3/avro/io.py
index f417b66..b944904 100644
--- a/lang/py3/avro/io.py
+++ b/lang/py3/avro/io.py
@@ -49,6 +49,7 @@ import sys
 
 from avro import schema
 
+logger = logging.getLogger(__name__)
 
 # ------------------------------------------------------------------------------
 # Constants
@@ -249,7 +250,7 @@ class BinaryDecoder(object):
     try:
       return input_bytes.decode('utf-8')
     except UnicodeDecodeError as exn:
-      logging.error('Invalid UTF-8 input bytes: %r', input_bytes)
+      logger.error('Invalid UTF-8 input bytes: %r', input_bytes)
       raise exn
 
   def check_crc32(self, bytes):

http://git-wip-us.apache.org/repos/asf/avro/blob/64f898c4/lang/py3/avro/ipc.py
----------------------------------------------------------------------
diff --git a/lang/py3/avro/ipc.py b/lang/py3/avro/ipc.py
index 973e674..792f764 100644
--- a/lang/py3/avro/ipc.py
+++ b/lang/py3/avro/ipc.py
@@ -32,6 +32,8 @@ from avro import io as avro_io
 from avro import protocol
 from avro import schema
 
+logger = logging.getLogger(__name__)
+
 # ------------------------------------------------------------------------------
 # Constants
 
@@ -174,7 +176,7 @@ class BaseRequestor(object, metaclass=abc.ABCMeta):
     if self._send_protocol:
       request_datum['clientProtocol'] = str(self._local_protocol)
 
-    logging.info('Sending handshake request: %s', request_datum)
+    logger.info('Sending handshake request: %s', request_datum)
     HANDSHAKE_REQUESTOR_WRITER.write(request_datum, encoder)
 
   def _WriteCallRequest(self, message_name, request_datum, encoder):
@@ -199,7 +201,7 @@ class BaseRequestor(object, metaclass=abc.ABCMeta):
     self._WriteRequest(message.request, request_datum, encoder)
 
   def _WriteRequest(self, request_schema, request_datum, encoder):
-    logging.info('writing request: %s', request_datum)
+    logger.info('writing request: %s', request_datum)
     datum_writer = avro_io.DatumWriter(request_schema)
     datum_writer.write(request_datum, encoder)
 
@@ -214,7 +216,7 @@ class BaseRequestor(object, metaclass=abc.ABCMeta):
       schema.AvroException on ???
     """
     handshake_response = HANDSHAKE_REQUESTOR_READER.read(decoder)
-    logging.info('Processing handshake response: %s', handshake_response)
+    logger.info('Processing handshake response: %s', handshake_response)
     match = handshake_response['match']
     if match == 'BOTH':
       # Both client and server protocol hashes match:
@@ -370,7 +372,7 @@ class Responder(object, metaclass=abc.ABCMeta):
       writer_schema = remote_message.request
       reader_schema = local_message.request
       request = self._ReadRequest(writer_schema, reader_schema, buffer_decoder)
-      logging.info('Processing request: %r', request)
+      logger.info('Processing request: %r', request)
 
       # perform server logic
       try:
@@ -407,7 +409,7 @@ class Responder(object, metaclass=abc.ABCMeta):
       The requested Protocol.
     """
     handshake_request = HANDSHAKE_RESPONDER_READER.read(decoder)
-    logging.info('Processing handshake request: %s', handshake_request)
+    logger.info('Processing handshake request: %s', handshake_request)
 
     # determine the remote protocol
     client_hash = handshake_request.get('clientHash')
@@ -436,7 +438,7 @@ class Responder(object, metaclass=abc.ABCMeta):
       handshake_response['serverProtocol'] = str(self.local_protocol)
       handshake_response['serverHash'] = self._local_hash
 
-    logging.info('Handshake response: %s', handshake_response)
+    logger.info('Handshake response: %s', handshake_response)
     HANDSHAKE_RESPONDER_WRITER.write(handshake_response, encoder)
     return remote_protocol
 
@@ -649,9 +651,9 @@ def _MakeHandlerClass(responder):
     def do_POST(self):
       reader = FramedReader(self.rfile)
       call_request = reader.Read()
-      logging.info('Serialized request: %r', call_request)
+      logger.info('Serialized request: %r', call_request)
       call_response = responder.Respond(call_request)
-      logging.info('Serialized response: %r', call_response)
+      logger.info('Serialized response: %r', call_response)
 
       self.send_response(200)
       self.send_header('Content-type', AVRO_RPC_MIME)
@@ -660,7 +662,7 @@ def _MakeHandlerClass(responder):
       framed_writer = FramedWriter(self.wfile)
       framed_writer.Write(call_response)
       self.wfile.flush()
-      logging.info('Response sent')
+      logger.info('Response sent')
 
   return AvroHTTPRequestHandler
 

http://git-wip-us.apache.org/repos/asf/avro/blob/64f898c4/lang/py3/avro/schema.py
----------------------------------------------------------------------
diff --git a/lang/py3/avro/schema.py b/lang/py3/avro/schema.py
index c3f73c5..7ed3b54 100644
--- a/lang/py3/avro/schema.py
+++ b/lang/py3/avro/schema.py
@@ -45,6 +45,7 @@ import json
 import logging
 import re
 
+logger = logging.getLogger(__name__) 
 
 # ------------------------------------------------------------------------------
 # Constants
@@ -447,7 +448,7 @@ class Names(object):
       raise SchemaParseException(
           'Avro name %r already exists.' % schema.fullname)
 
-    logging.log(DEBUG_VERBOSE, 'Register new name for %r', schema.fullname)
+    logger.log(DEBUG_VERBOSE, 'Register new name for %r', schema.fullname)
     self._names[schema.fullname] = schema
 
 


Mime
View raw message