Commits

Ginés Martínez Sánchez committed 5c22a6c Draft

improve logging system

Comments (0)

Files changed (27)

 
 - Improve the documentation.
 - Coverage 100% tests.
+- SSL
+- Auth
+- Periodic Callback
 GinsFSM
 =======
 
+
+GinsFSM forma parte de GObj-Ecosistema, un sistema donde el elemento basico
+es un GObj, un objecto cuyo comportamiento esta definido por un automata,
+y donde toda la comunicación con el objecto se realiza a traves de eventos.
+El GObj define qué eventos de entrada soporta, y que eventos de salida ofrece.
+A un GObj puedes enviarle un evento, o subscribirte a sus eventos de salida.
+
+Puedes enviar y subscribir eventos de un GObj que esté en tu mismo thread,
+en otros threads o subprocesos de tu aplicación, o en procesos corriendo
+en la misma o diferente maquina. Esto incluye también a los browsers.
+
+El transporte de los eventos se realiza mediante el protocolo websocket.
+Cada thread o subproceso, representado por el object GAplic,
+puede levantar un servicio websocket como
+servidor o establecer tantas conexiones cliente como necesite (GRouter)
+Se puede configurar un servidor websocket en cualquier puerto.
+tambien en el puerto 80 o 443,
+en este caso retringido a usar un servidor sockjs integrado
+en el framework Pyramid, soportando ademas conexiones de browsers.
+
+Para los GObj corriendo en browsers se usa la libreria sockjs. Esto permite
+usar tanto navegadores modernos que soporten websocket, como navegadores
+antiguos que no dispongan de websocket.
+
+En el GObj-Ecosistema los threads o suprocesos estan representados por el
+objecto GAplic, que además de ser el contenedor de todos los GObj del thread,
+y suministrar el event loop, se puede definir con un nombre y uno varios roles.
+
+Puedes configurar una red de gaplics, e intercambiar eventos entre ellos
+simplemente conociendo el nombre o role del gaplic, y el nombre del gobj
+
 Can you draw your development?
 
 Can you view the behaviour of your application in real time?

ginsfsm/__init__.py

 __title__ = 'ginsfsm'
 __author__ = 'Ginés Martínez'
 __license__ = 'MIT License'
-__copyright__ = 'Copyright 2013 Ginés Martínez'
+__copyright__ = 'Copyright 2012-2013 Ginés Martínez'
 
-
-# Set default logging handler to avoid "No handler found" warnings.
-import logging
-try:  # Python 2.7+
-    from logging import NullHandler
-except ImportError:
-    class NullHandler(logging.Handler):
-        def emit(self, record):
-            pass
-
-logging.getLogger(__name__).addHandler(NullHandler())

ginsfsm/c_sock.py

 import socket
 import time
 import errno
-import logging
 import sys
 import warnings
 import os
     except Exception:
         # All other systems
         if "linux" in sys.platform:
-            logging.warning("epoll module not found; using select()")
+            print("epoll module not found; using select()")
         _poll = _Select

ginsfsm/c_srv_sock.py

 except ImportError:
     ssl = None
 
-import logging
 import errno
 import socket
 from ginsfsm.gobj import GObj
                     self.port = port
                     break
         if port:
-            logging.info("Listening %r at host %r, port %r..." % (
-                self, host, port)
-            )
+            if self.logger:
+                self.logger.info("Listening %r at host %r, port %r..." % (
+                    self, host, port)
+                )
             self.listen(1024)
         else:
             self.logger.error("ERROR at %r NO listening port!", self)

ginsfsm/deferred.py

 # -*- coding: utf-8 -*-
-import logging
 from collections import (
     Callable,
     deque,
         for deferred in self.callbacks:
             if deferred.ref == ref:
                 return deferred(**kwargs)
-        logging.error("ERROR __call__ deferred ref %r NOT FOUND" % (
+        print("ERROR __call__ deferred ref %r NOT FOUND" % (
             deferred.ref))
 
     def delete(self, ref):
             if deferred.ref == ref:
                 self.callbacks.remove(deferred)
                 return
-        logging.error("ERROR delete deferred ref %r NOT FOUND" % deferred.ref)
+        print("ERROR delete deferred ref %r NOT FOUND" % deferred.ref)

ginsfsm/dl_list.py

 # -*- coding: utf-8 -*-
 """ Porting of DL_LIST.C
 """
-import logging
 
 
 class ListItem(object):
 
 def check_links(item):
     if item.prev or item.next:
-        logging.error("ERROR dl_list.py: INSERTING ITEM WITH PREVIOUS LINKS")
+        print("ERROR dl_list.py: INSERTING ITEM WITH PREVIOUS LINKS")
         return False
     return True
 
     """ Delete current item
     """
     if curr is None:
-        logging.error("ERROR dl_delete(): DELETING ITEM NULL")
+        print("ERROR dl_delete(): DELETING ITEM NULL")
         return False
 
     #
     #     Check list
     #
     if dl.head is None or dl.tail is None or dl.itemsInContainer == 0:
-        logging.error("ERROR dl_delete(): DELETING ITEM IN EMPTY LIST")
+        print("ERROR dl_delete(): DELETING ITEM IN EMPTY LIST")
         return False
 
     #

ginsfsm/examples/essential_gobjs/ontimer.py

     :members:
 
 """
+import logging
+logging.basicConfig(level=logging.DEBUG)
+
 import os
 
+from ginsfsm.gaplic import GAplic
 from ginsfsm.gobj import GObj
-from ginsfsm.gaplic import GAplic
 from ginsfsm.c_timer import GTimer
 
-import logging
-logging.basicConfig(level=logging.DEBUG)
-
 
 def ac_exec_command(self, event):
     if self.config.verbose:
 
 
 if __name__ == "__main__":
+    logging.basicConfig(level=logging.DEBUG)
     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument(
     args = parser.parse_args()
 
     local_conf = {
-        'GObj.trace_mach': True if args.verbose else False,
+        'GObj.trace_mach': True,
+        'GObj.trace_creation': True,
+        'GObj.trace_subscription': True,
         'GObj.logger': logging,
     }
 

ginsfsm/examples/router/test_router.py

 Routing events between gaplics.
 ===============================
 
+You can run this file with ``gserve test_router.ini``
+
 .. autoclass:: Sample1
     :members:
 

ginsfsm/examples/sockjs/test_sockjs_server.py

 
 It uses :class:`ginsfsm.protocols.wsgi.server.c_wsgi_server.GWsgiServer`.
 
+You can run this file with ``gserve test_sockjs_server.ini``
+
 .. autofunction:: main
 
 """

ginsfsm/examples/wsgi/multiple_wsgi_server.py

 
 It uses :class:`ginsfsm.protocols.wsgi.server.c_wsgi_server.GWsgiServer`.
 
+You can run this file with ``gserve multiple_wsgi_server.ini``
+
 .. autofunction:: main
 
 """

ginsfsm/examples/wsgi/simple_wsgi_server.py

 
 It uses :class:`ginsfsm.protocols.wsgi.server.c_wsgi_server.GWsgiServer`.
 
+You can run this file with ``gserve simple_wsgi_server.ini``
+
 .. autofunction:: main
 
 """

ginsfsm/gaplic.py

 """
 import time
 import threading
-import logging
 from collections import deque
 
 from ginsfsm.globals import (
         self.deferred_list = DeferredList()
 
         logger = ini_settings.get('logger', None)
-        if logger is None:
-            # TODO use package caller
+        if not logger:
+            import logging
             self.logger = logging.getLogger(__name__)
-            if not self.logger:
-                self.logger = logging
         else:
             if isinstance(logger, string_types):
+                import logging
                 self.logger = logging.getLogger(logger)
             else:
                 self.logger = logger
+        if not self.logger:
+            logging.basicConfig(level=logging.DEBUG)
+            self.logger = logging
+
         self.start_up()
 
     def start_up(self):
                     destination = self._resolv_destination(event.destination)
                     cur_ident = threading.current_thread().ident
                     if cur_ident != self._thread_ident:
-                        logging.error("??????????????????")
+                        if self.logger:
+                            self.logger.error("??????????????????")
 
                     dst_ident = destination.gaplic._thread_ident
                     if cur_ident == dst_ident:
                         if gaplic:
                             gaplic.enqueue_event(event)
                 except Exception:
-                    logging.error("Exception gaplic.__process_qevent",
-                                  exc_info=True)
+                    if self.logger:
+                        self.logger.error("Exception gaplic.__process_qevent")
 
         return False
 
         The exception itself is not passed explicitly, but is available
         in sys.exc_info.
         """
-        logging.error("Exception in callback %r", callback, exc_info=True)
+        if self.logger:
+            self.logger.error(
+                "Exception in callback %r",
+                callback,
+                exc_info=True)
 
 
 #===============================================================

ginsfsm/gconfig.py

     bytes_,
 )
 
-import logging  # use root logger
-
 accepted_types = (str, int, bool, list, tuple, dict, bytes)
 
 
 
     FLAG_DIRECT_ATTR = 0x01  # write directly in gobj (not in config attr).
 
-    def __init__(self, templates):
+    def __init__(self, templates, logger=None):
         self._gconfig_template = {}
         self.config = _Config()
+        self.logger = logger
 
         if not isinstance(templates, (list, tuple)):
             templates = [templates]
                 self._write_parameter(parameter, value)
             except Exception as e:
                 # In real time don't raise exceptions, only at setup
-                logging.exception(e)
+                if self.logger:
+                    self.logger.exception(e)
 
     def filter_parameters(self, **settings):
         """ Filter the parameters in settings belongs to gobj.
         # [type, default_value, flag, validate_function, desc]
         definition = self._gconfig_template.get(parameter, None)
         if definition is None:
-            logging.error(
+            self.logger and self.logger.error(
                 "ERROR %r in write_parameter(%r):"
                 "\n  name = %r\n  value = %r" % (
                 "PARAMETER NAME INVALID",
             msg = "ERROR %s in write_parameter(%r):" \
                 "\n  name = %r\n  value = %r" % (
                 e, self, parameter, value)
-            logging.exception(msg)
+            self.logger and self.logger.exception(msg)
             raise GConfigValidateError(msg)
 
         if isinstance(value, string_types):
             if prefix[0] == 'app':
                 value = get_global_app(prefix[1])
                 if not value:
-                    logging.error("ERROR get_global_app (%s) NOT LOADED" %
-                                  prefix[1])
+                    self.logger and self.logger.error(
+                        "ERROR get_global_app (%s) NOT LOADED" %
+                        prefix[1])
 
         if flag and GConfig.FLAG_DIRECT_ATTR:
             destobj = self
                 if not callable(value):
                     # Override methods only with callables
                     if value is not None:
-                        logging.error(
+                        self.logger and self.logger.error(
                             "ERROR cannot override parameter (%r,%r)" % (
                                 parameter, value))
                     return
         definition = self._gconfig_template.get(parameter, None)
         if not definition:
             # In real time, we log the errors instead of raise.
-            logging.error("ERROR in %r, doesn't exist parameter (%r)" % (
+            self.logger and self.logger.error(
+                "ERROR in %r, doesn't exist parameter (%r)" % (
                 self, parameter))
             return None
         flag = definition[2]
             value = getattr(read_in, parameter)
         except AttributeError:
             # In real time, we log the errors instead of raise.
-            logging.error("ERROR in %r, doesn't exist parameter (%r)" % (
+            self.logger and self.logger.error(
+                "ERROR in %r, doesn't exist parameter (%r)" % (
                 self, parameter))
             return None
         return value

ginsfsm/globals.py

 """
 import atexit
 import threading
-import logging
 
 _global_apps = {}
 """ _global_apps is a dictionary with the wsgi applications
         thread_ident = threading.current_thread().ident
     global_main_gaplic = get_global_main_gaplic()
     if global_main_gaplic is None:
-        logging.error(
+        print(
             "ERROR global main gaplic is NOT SET. "
             "Have you called set_global_main_gaplic()?."
         )
 # -*- coding: utf-8 -*-
 """ Porting of GSMG.C
 """
-import logging
-
 from ginsfsm.utils import string_to_bytearray
 
 from ginsfsm.dl_list import (
         if gmsg.cur_size >= gmsg.max_size:
             msg = "ERROR segm_create(): MAXIMUM size reached (%d over %d)" % (
                 gmsg.cur_size, gmsg.max_size)
-            logging.error(msg)
+            gmsg.logger and gmsg.logger.error(msg)
             raise SegmError(msg)  # Alcanzado máximo tamaño
 
         data_size = gmsg.max_size - gmsg.cur_size
 
 
 class GMsg(ListItem):
-    def __init__(self, segm_size, max_size=0):
+    def __init__(self, segm_size, max_size=0, logger=None):
         """ Message Manager
         The message are organized in segments.
 
         :param segm_size: Maximum size of a segment
         :param max_size:
         """
+        self.logger = logger
         self.segm_size = segm_size  # tamaño segmentos datos
         # tamaño máximo total, si es 0, igual a segm_size (like PACKET!!!)
         self.max_size = max_size if max_size > 0 else segm_size
         if ln < self.bytesleft():
             self.sublen = ln
             return True
-        logging.warning("Not enough data for subsetdata: (%d over %d)" % (
-                        ln, self.bytesleft()))
+        self.logger and self.logger.warning(
+            "Not enough data for subsetdata: (%d over %d)" % (
+            ln, self.bytesleft()))
         self.sublen = 0
         return False
 
         """
         segm = dl_last(self.dl_segm)
         if not segm or segm.tail < ln:
-            logging.error("gmsg_unputdata(): ERROR NO HAY SUFICIENTE LEN")
+            self.logger and self.logger.error(
+                "gmsg_unputdata(): ERROR NO HAY SUFICIENTE LEN")
             return False
         segm.tail -= ln
         return True
         """
         segm = self.segm_create()
         if not segm:
-            logging.debug("gmsg_new_segm(): ERROR CREANDO SEGMENTO")
+            self.logger and self.logger.error(
+                "gmsg_new_segm(): ERROR CREANDO SEGMENTO")
             return False
         dl_add(self.dl_segm, segm)
         return True
         if ln == 0:
             ln = len(data)
         if ln > self.segm_size:
-            logging.error("gmsg_insert_data(): DATA TOO LARGE %d", ln)
+            self.logger and self.logger.error(
+                "gmsg_insert_data(): DATA TOO LARGE %d", ln)
             return False
 
         segm = dl_first(self.dl_segm)
         if not segm:
-            logging.error("ERROR gmsg_insert_data(): No first segm")
+            self.logger and self.logger.error(
+                "ERROR gmsg_insert_data(): No first segm")
             return False
 
         seg_len = segm.segm_size - segm.tail
             segm.data[0:ln] = data[0:ln]
             segm.tail += ln
             return True
-        logging.warning("Cannot insert data: full data.")
+        self.logger and self.logger.warning("Cannot insert data: full data.")
         return False  # NO debe pasar nunca por aqui
 
     def mark_pos_write(self):
             #
             #  No hay fixed segm
             #
-            logging.error("ERROR gmsg_overwrite_data() NO FIXED SEGM")
+            self.logger and self.logger.error(
+                "ERROR gmsg_overwrite_data() NO FIXED SEGM")
             return 0
 
         data = string_to_bytearray(data)
 .. autoexception:: EventNotAcceptedError
 
 """
-import logging
 import re
 import ginsfsm.globals  # made it import available
 from ginsfsm.compat import string_types
 
 
 GOBJ_GCONFIG = {
-    'trace_traverse': [bool, False, 0, None, 'Display traverse search'],
+    'trace_traverse': [bool, False, 0, None, 'Trace traverse search'],
+    'trace_creation': [
+        bool, False, GConfig.FLAG_DIRECT_ATTR, None,
+        'Trace creation/destroy of gobj'],
+    'trace_subscription': [bool, False, 0, None, 'Trace event subscribing'],
     're_name': [
         str, None, 0, None,
         'Regular expression name to search the gobj in the resource tree.'
         self.re_matched_name = ''  # matched name when using re_name
 
         gconfig = add_gconfig(gconfig, GOBJ_GCONFIG)
-        GConfig.__init__(self, gconfig)
+        GConfig.__init__(self, gconfig, self.logger)
 
     def __del__(self):
-        if self.logger:
-            self.logger.debug("Destroyed! <-- %r" % (self))
+        if self.trace_creation:
+            self.logger and self.logger.info("Destroyed! <-- %r" % (self))
 
     def __str__(self):
         name = "%s" % (self.name)
         if self.__random_name__:
             name = self.get_random_name(name)
 
-        if self.logger:
-            self.logger.debug("Creating --> '%s:%s'" % (
-                gclass.__name__, name))
-
         gobj = gclass()
 
         if name:
         if gobj.config.re_name:
             gobj._re_compiled_name = re.compile(gobj.config.re_name)
 
+        if gobj.trace_creation:
+            self.logger and self.logger.info("Creating --> '%s:%s'" % (
+                gclass.__name__, name))
+
         if gobj.__unique_name__:
             registered = self.gaplic._register_unique_gobj(gobj)
             if not registered:
 
         gobj.start_up()
 
-        if self.logger:
+        if gobj.trace_creation and self.logger:
             if gobj.__unique_name__:
                 unique = '!'
             else:
                 unique = ' '
-            self.logger.debug("Created <--%s '%r'" % (unique, gobj))
+            self.logger.info("Created <--%s '%r'" % (unique, gobj))
 
         return gobj
 
     def destroy_gobj(gobj):
         """ Destroy a gobj
         """
-        if gobj.logger:
-            gobj.logger.debug("Destroying --> %r" % (gobj))
+        if gobj.config.trace_creation and gobj.logger:
+            gobj.logger.info("Destroying --> %r" % (gobj))
 
         if gobj._destroyed:
             if gobj.logger:
             return self.post_event(destination, event)
 
         if destination._destroyed:
-            logging.error(
+            self.logger and self.logger.error(
                 "ERROR internal: sending event %r to a destroyed gobj %r" % (
                     event.event_name, destination)
             )
                     (self, event_name, subscriber_gobj))
             self.delete_subscription(event_name, subscriber_gobj)
         subscription = _Subscription(self, event_name, subscriber_gobj, **kw)
-        if self.logger:
-            self.logger.debug('NEW %r' % subscription)
+        if self.config.trace_subscription and self.logger:
+            self.logger.info('NEW %r' % subscription)
         self._dl_subscriptions.add(subscription)
         self._some_subscriptions = True
         return subscription
 
     def delete_subscription_by_object(self, subscription):
         if subscription in self._dl_subscriptions:
+            if self.config.trace_subscription and self.logger:
+                self.logger.info('DEL %r' % subscription)
             self._dl_subscriptions.remove(subscription)
             if len(self._dl_subscriptions) == 0:
                 self._some_subscriptions = False
         :param subscriber_gobj: subscriber gobj.
         """
         sub = self._find_subscription(event_name, subscriber_gobj)
-        if self.logger:
-            self.logger.debug('DEL %r' % sub)
+        if self.config.trace_subscription and self.logger:
+            self.logger.info('DEL %r' % sub)
         if sub:
             if sub.kw.get('__hard_subscription__', None):
                 if self.logger:
             if not force:
                 if sub.kw.get('__hard_subscription__'):
                     continue
-            if self.logger:
-                self.logger.debug('DEL %r' % sub)
+
+            if self.config.trace_subscription and self.logger:
+                self.logger.info('DEL %r' % sub)
             self._dl_subscriptions.remove(sub)
 
         if len(self._dl_subscriptions) == 0:

ginsfsm/protocols/http/common/response.py

 
 """
 
-import logging
 import time
 
 from ginsfsm import __version__
                 towrite = data[:cl - self.content_bytes_written]
                 self.content_bytes_written += len(towrite)
                 if towrite != data and not self.logged_write_excess:
-                    logging.error(
+                    self.gsock.logger and self.gsock.logger.error(
                         'application-written content exceeded the number of '
                         'bytes specified by Content-Length header (%s)' % cl)
                     self.logged_write_excess = True

ginsfsm/protocols/http/common/utilities.py

 """Utility functions
 """
 
-import asyncore
-import logging
 import re
 import time
 import calendar

ginsfsm/protocols/http/server/c_http_clisrv.py

 
 """
 from collections import deque
-import logging
 import traceback
 
 from ginsfsm.c_timer import GTimer
 def ac_http_response(self, event):
     response = event.response
     if not isinstance(response, HttpResponse):
-        logging.error(
+        self.logger and self.logger.error(
             "ERROR response doesn't mach HttpResponse %s" %
             response.request.path)
 
     if response.request != self.responding_request:
-        logging.error(
+        self.logger and self.logger.error(
             "ERROR response doesn't mach responding request %s" %
             response.request.path)
 
     if self.responding_response:
-        logging.error(
+        self.logger and self.logger.error(
             "ERROR responding_response is BUSY, of %s" %
             response.request.path)
     self.responding_response = response
         return
 
     except:
-        logging.exception('Exception when serving %s' % response.request.path)
+        self.logger and self.logger.exception(
+            'Exception when serving %s' % response.request.path)
         if not response.wrote_header:
             if self.parent.config.expose_tracebacks:
                 body = traceback.format_exc()
             To supply asynchronous access to high level.
         """
         if not self.responding_response:
-            logging.error("ERROR channel.write() with no responding_response")
+            self.logger and self.logger.error(
+                "ERROR channel.write() with no responding_response")
             return
         self.responding_response.write(data)
 
             To supply asynchronous access to high level.
         """
         if not self.responding_response:
-            logging.error("ERROR channel.flush() with no responding_response")
+            self.logger and self.logger.error(
+                "ERROR channel.flush() with no responding_response")
             return
         self.responding_response.flush(callback)
 
         """
         if response is None:
             if not self.responding_response:
-                logging.error("ERROR channel.finish()"
-                              " with no responding_response")
+                self.logger and self.logger.error(
+                    "ERROR channel.finish()"
+                    " with no responding_response")
                 return
             response = self.responding_response
         response.finish()

ginsfsm/protocols/sockjs/server/c_sockjs_server.py

 
 """
 
-from pyramid.traversal import resource_path
 from pyramid.security import (
     Allow,
     Everyone,
         # Initialize io_loop
         #self.io_loop = io_loop or ioloop.IOLoop.instance()
 
-        self.websockets_enabled = 'websocket' not in self.config.disabled_transports
+        disabled_transports = self.config.disabled_transports
+        self.websockets_enabled = 'websocket' not in disabled_transports
         self.cookie_needed = self.config.jsessionid
 
         # Sessions
         self._sessions = sessioncontainer.SessionContainer()
 
         #check_interval = self.settings['session_check_interval'] * 1000
-        #self._sessions_cleanup = ioloop.PeriodicCallback(self._sessions.expire,
+        #self._sessions_cleanup =ioloop.PeriodicCallback(self._sessions.expire,
         #                                                 check_interval,
         #                                                 self.io_loop)
         #self._sessions_cleanup.start()
 
     # Broadcast helper
     def broadcast(self, clients, msg):
-        """Optimized `broadcast` implementation. Depending on type of the session, will json-encode
+        """Optimized `broadcast` implementation.
+        Depending on type of the session, will json-encode
         message once and will call either `send_message` or `send_jsonifed`.
 
         `clients`

ginsfsm/protocols/sockjs/server/c_websocket.py

 import hashlib
 import struct
 import uuid
-import logging
 
 from ginsfsm import __version__
 from ginsfsm.utils import hexdump
     if hd.h_reserved_bits:
         # client is using as-yet-undefined extensions; abort
         hd.error = True
-        logging.error(
+        gmsg.logger and gmsg.logger.error(
             "ERROR websocket header: using as-yet-undefined h_reserved_bits")
         return hd
 
         if hd.h_payload_len >= 126:
             # control frames must have payload < 126; abort
             hd.error = True
-            logging.error(
+            gmsg.logger and gmsg.logger.error(
                 "ERROR websocket header: too big control frame payloda")
     else:
         #
         if iam_server and not hd.h_mask:
             # Unmasked frame; abort
             hd.error = True
-            logging.error(
+            gmsg.logger and gmsg.logger.error(
                 "ERROR websocket header: iam_server but unmasked frame")
 
     return hd
 def ac_timeout_waiting_handshake(self, event):
     """ Too much time waiting the handshake.
     """
-    logging.error("ERROR websocket TIMEOUT waiting HANDSHAKE: %r" % self)
+    self.logger and self.logger.error(
+        "ERROR websocket TIMEOUT waiting HANDSHAKE: %r" % self)
     self.on_close_broadcasted = True  # no on_open was broadcasted
     self.close()
 
     """ Timeout frame start.
         Too much time waiting the frame header.
     """
-    logging.error("ERROR websocket TIMEOUT waiting PAYLOAD data")
+    self.logger and self.logger.error(
+        "ERROR websocket TIMEOUT waiting PAYLOAD data")
     self.close()
 
 
         self.closed = False  # channel closed
         self.on_close_broadcasted = False  # event on_close already broadcasted
         self.message_header = None
-        self.frame_gmsg = GMsg(1024, self.config.outbuf_overflow)
+        self.frame_gmsg = GMsg(1024, self.config.outbuf_overflow, self.logger)
         self.message_buffer = None
         self.parsing_request = None  # A request parser instance
         self.parsing_response = None  # A response parser instance

ginsfsm/protocols/sockjs/server/proto.py

 
     SockJS protocol related functions
 """
-import logging
-
 # TODO: Add support for ujson module once they can accept unicode strings
 
 # Try to find best json encoder available
     json_encode = lambda data: simplejson.dumps(data, separators=(',', ':'))
     json_decode = lambda data: simplejson.loads(data)
     JSONDecodeError = ValueError
-
-    logging.debug('sockjs will use simplejson module')
+    print('sockjs will use simplejson module')
 except ImportError:
     # Use slow json
     import json
 
-    logging.debug('sockjs will use json module')
+    print('sockjs will use json module')
 
     json_encode = lambda data: json.dumps(data, separators=(',', ':'))
     json_decode = lambda data: json.loads(data)

ginsfsm/protocols/wsgi/common/wsgi_response.py

 
 """
 
-import logging
 from ginsfsm.buffers import ReadOnlyFileBasedBuffer
 from ginsfsm.compat import (
     reraise,
                     # waiting for more data when there are too few bytes
                     # to service content-length
                     self.close_on_finish = True
-                    logging.error(
+                    self.wsgi_server.logger and self.wsgi_server.logger.error(
                         'application returned too few bytes (%s) '
                         'for specified Content-Length (%s) via app_iter' % (
                             self.content_bytes_written, cl),

ginsfsm/router.py

 para ver si puede entregar los eventos.
 
 El registro global de gobjs... todos los gaplics deberian registrarse alli.
+"""
 
-
-"""
 import datetime
 from collections import deque
 from ginsfsm.gobj import (
                     self.remove_external_subscription(subscription_reference)
                 else:
                     # TODO: find and delete external subscription
-                    self.logging.error("ERROR no __subscription_reference__")
+                    self.logger.error("ERROR no __subscription_reference__")
 
                 # simple ack, no checkout, for the sender could remove the msg.
                 ack = intra_event.copy('__event_ack__')

ginsfsm/smachine.py

             if self._last_state != state_id:
                 hora = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                 logger = self.logger
-                logger and logger.debug("%s%s - mach: (%s:%s), new_st: %s" % (
+                logger and logger.info("%s%s - mach: (%s:%s), new_st: %s" % (
                     hora,
                     self._tab(),
                     self.__class__.__name__, self.name,
             if action[0]:
                 action_name = action[0].__name__
             hora = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
-            logger and logger.debug(
+            logger and logger.info(
                 "%s%s-> mach: (%s:%s), st: %s, ev: (%s,%s), ac: %s()" % (
                     hora,
                     self._tab(),
 
         if trace_mach:
             hora = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
-            logger and logger.debug("%s%s<- mach: (%s:%s), st: %s, ret: %s" % (
+            logger and logger.info("%s%s<- mach: (%s:%s), st: %s, ret: %s" % (
                 hora,
                 self._tab(),
                 self.__class__.__name__, self.name,
 # -*- coding: utf-8 -*-
-import logging
 from ginsfsm.compat import (
     urlparse,
     text_type,
     for url in urls:
         o = urlparse.urlparse(url)
         if not o.hostname or not o.scheme:
-            logging.error("Can't get HOST from URL %r" % url)
+            print("Can't get HOST from URL %r" % url)
             continue
         if not o.port:
             if o.scheme in ('wss', 'https'):
         else:
             port = o.port
         if not port:
-            logging.error("Can't get PORT from URL %r" % url)
+            print("Can't get PORT from URL %r" % url)
             continue
 
         routes.append((o.hostname, port),)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.