/ Published in: Python
These logging functions will be improved and added into the SocketServer_Server.py to log information from programs on machines on the same network, but not directly connected to each other.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# SocketServer_Logging.py # Version: 1.0 # Use: Internal Application (Work) # Purpose: To provide logging methods and classes for the logging server. # Copyright (C)2014 Jordan Rowles # GNU General Public License Version 3 or Later import logging as log def customLogger(name): formatter = logging.Formatter(fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s") handler = logging.StreamHandler() handler.setFormatter(formatter) logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) logger.addHandler(handler) return logger ''' USE: * Module1.py * import LoggingForServer as Log logger = Log.setup_custom_logger('root') logger.debug('Module1 Message') import Module2 * Module2.py * import LoggingForServer as Log logger = logging.getLogger('root') logger.debug('Module2 Message') * OUTPUT * 2014-04-11 20:08:40,049 - DEBUG - Module1 - Module1Message 2014-04-11 20:08:40,050 - DEBUG - Module2 - Module2Message '''
URL: SocketServer-Logging