def setup_logging(): logger = logging.getLogger() # NOTE: In order to use this example, you must generate a client certificate. # Simply use the loghog-client-cert command on the machine that will # run loghogd: # # $ sudo loghog-client-cert `hostname` # # The above will generate a file called `hostname`.pem. Use this file with # your project, along with loghogd-ca.cert to encrypt all traffc between # your application and the server ssl_info = { 'pemfile': '/PATH/TO/CLIENT.pem', 'cacert': '/etc/loghogd/certs/loghogd-ca.cert', } # Specify an ssl_info dict, as well as a port value to enable SSL. # Typically, port 5577 is used for SSL-protected connections. # print_debug is enabled to help identify any issues. handler = LoghogHandler('my-first-app', port=5577, ssl_info=ssl_info, print_debug=True) handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)
def setup_logging(): logger = logging.getLogger() # NOTE: In order to use this example, you must generate a client certificate. # Simply use the loghog-client-cert command on the machine that will # run loghogd: # # $ sudo loghog-client-cert `hostname` # # The above will generate a file called `hostname`.pem. Use this file with # your project, along with loghogd-ca.cert to encrypt all traffc between # your application and the server ssl_info = { 'pemfile': '/PATH/TO/CLIENT.pem', 'cacert': '/etc/loghogd/certs/loghogd-ca.cert', } handler = LoghogHandler('kitchen-sink-app', host='localhost', # Default is 'localhost' port=5577, # Default is 5566. Port 5577 is usually SSL enabled stream=True, # Default is True secret='my-big-secret', # Specify this if the server expects it compression=True, # Default is False hostname='example01', # Default is determined automatiaclly ssl_info=ssl_info, # Default is None for disabled SSL max_buffer_size=1024, # How many messages to enque if the server is down, before dropping the oldest ones print_debug=True # Default is False. Prints connection errors to STDOUT ) handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)
def setup_logging(): logger = logging.getLogger() handler = LoghogHandler('my-first-app') handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)
def test_encode(self): handler = LoghogHandler('test-app') data = handler._encode(self.rec) payload = self.unpack_payload(data) msg = self.parse_message(payload) self.check_message_content(msg)
def setup_logging(): logger = logging.getLogger() # Set print_debug = True to see connection errors handler = LoghogHandler('my-first-app', print_debug=True) handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)
def test_encode_with_zlib(self): handler = LoghogHandler('test-app', compression=True) data = handler._encode(self.rec) payload = self.unpack_payload(data) payload = zlib.decompress(payload) msg = self.parse_message(payload) self.check_message_content(msg)
def test_encode_secret(self): handler = LoghogHandler('test-app', secret='qqq123') data = handler._encode(self.rec) payload = self.unpack_payload(data) msg = self.parse_message(payload) self.check_message_content(msg) self.verify_signature('qqq123', msg)
def setup_logging(): logger = logging.getLogger() # You can log messages to a remote server. Simply specify the address parameter. # Don't forget to listen on the appropriate address on the server since # by default it only listens on localhost. handler = LoghogHandler('my-first-app', host='localhost', port=5566) handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)
def setup_logging(): logger = logging.getLogger() # If the server-side specifies a secret, you must provide it here as well. # If a secret is specified here, all messages are signed using HMAC. # Any messages with invalid signatures will be ignored by the server. handler = LoghogHandler('app-with-secret', secret='my-big-secret') handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)
def setup_logging(): logger = logging.getLogger() # To send log messages over UDP, simply set stream=False. # Note that UDP has several drawbacks compared to using TCP. Specifically: # # * Messages may be delivered out of order # * Messages may be dropped # * It is harder to debug any issues since packets are not explicitly rejected. # # On the other hand, sending data over UDP is master, since UDP is # connectionless, so there is less overhead for your application. handler = LoghogHandler('my-first-app', stream=False) handler.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) logger.addHandler(handler) logger.setLevel(logging.DEBUG)