Commit 78f50df4 authored by Javier Quinteros's avatar Javier Quinteros

Clean logging dependency from tdmsws

parent 874db2f5
......@@ -30,85 +30,12 @@ import cherrypy
import argparse
from cherrypy.process import plugins
import os
# import logging
# import logging.config
from datetime import datetime
import configparser
from .tdms import TDMS
from obspy import Trace
from io import BytesIO
# Logging configuration (hardcoded!)
LOG_CONF = {
'version': 1,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
},
'handlers': {
'tdmswslog': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'standard',
'filename': 'tdmsws.log',
'maxBytes': 10485760,
'backupCount': 20,
'encoding': 'utf8'
},
'cherrypyAccess': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'standard',
'filename': 'access.log',
'maxBytes': 10485760,
'backupCount': 20,
'encoding': 'utf8'
},
'cherrypyError': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'standard',
'filename': 'errors.log',
'maxBytes': 10485760,
'backupCount': 20,
'encoding': 'utf8'
},
},
'loggers': {
'main': {
'handlers': ['tdmswslog'],
'level': 'INFO'
},
'TdmswsAPI': {
'handlers': ['tdmswslog'],
'level': 'INFO',
'propagate': False
},
'StationAPI': {
'handlers': ['tdmswslog'],
'level': 'INFO',
'propagate': False
},
'DataselectAPI': {
'handlers': ['tdmswslog'],
'level': 'INFO',
'propagate': False
},
'cherrypy.access': {
'handlers': ['cherrypyAccess'],
'level': 'INFO',
'propagate': False
},
'cherrypy.error': {
'handlers': ['cherrypyError'],
'level': 'INFO',
'propagate': False
},
}
}
def str2date(dateiso):
"""Transform a string to a datetime.
......@@ -155,13 +82,11 @@ Service version:
class TdmswsAPI(object):
"""Main class including the dispatcher."""
def __init__(self, experiment, directory='.', loglevel='WARNING'):
def __init__(self, experiment, directory='.'):
"""Constructor of the TdmswsAPI object."""
# Save parameters
self.__experiment = experiment
self.__directory = directory
# self.__log = logging.getLogger('TdmswsAPI')
# self.__log.setLevel(loglevel)
# Get extra fields from the cfg file
cfgfile = configparser.RawConfigParser()
......@@ -176,7 +101,6 @@ class TdmswsAPI(object):
self.dataselect = DataselectAPI(experiment, directory)
self.station = StationAPI(experiment, directory)
# self.log = logging.getLogger('TdmswsAPI')
@cherrypy.expose
def index(self):
......@@ -202,13 +126,11 @@ class TdmswsAPI(object):
class StationAPI(object):
"""Object dispatching methods related to access to streams."""
def __init__(self, experiment, directory='.', loglevel='WARNING'):
def __init__(self, experiment, directory='.'):
"""Constructor of the StationAPI class."""
# Save parameters
self.__experiment = experiment
self.__directory = directory
# self.__log = logging.getLogger('StationAPI')
# self.__log.setLevel(loglevel)
# Get extra fields from the cfg file
cfgfile = configparser.RawConfigParser()
......@@ -221,7 +143,6 @@ class StationAPI(object):
if self.__loc == '':
self.__loc = '--'
@cherrypy.expose
def index(self, wsversion='1'):
if wsversion != '1':
......@@ -329,8 +250,7 @@ class StationAPI(object):
:type endtime: str
:param end: Alias of endtime
:type end: str
:param format: Specify format of result, either xml or text. If it's not specified the service must
return StationXML.
:param format: Format of result, either xml or text. Default value is xml (StationXML)
:type format: str
:returns: miniSEED data
:rtype: bytearray
......@@ -543,13 +463,11 @@ return StationXML.
class DataselectAPI(object):
"""Object dispatching methods related to access to streams."""
def __init__(self, experiment, directory='.', loglevel='WARNING'):
def __init__(self, experiment, directory='.'):
"""Constructor of the DataselectAPI class."""
# Save parameters
self.__experiment = experiment
self.__directory = directory
# self.__log = logging.getLogger('DataselectAPI')
# self.__log.setLevel(loglevel)
# Get extra fields from the cfg file
cfgfile = configparser.RawConfigParser()
......@@ -814,13 +732,7 @@ def main():
# Read general parameters
experiment = config.get('General', 'experiment')
# loglevel = config.get('General', 'loglevel')
# Logging configuration
# INFO is the default value
# logging.basicConfig(level=loglevel)
# logs = logging.getLogger('main')
# logs.setLevel(loglevel)
server_config = {
'global': {
......@@ -851,13 +763,6 @@ def main():
else:
cherrypy.engine.block()
# cherrypy.engine.signals.subscribe()
# cherrypy.engine.start()
# cherrypy.engine.block()
if __name__ == "__main__":
main()
# cherrypy.engine.signals.subscribe()
# cherrypy.engine.start()
# cherrypy.engine.block()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment