How to use the janus.janus_logging.janus_logger function in janus

To help you get started, we’ve selected a few janus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xamoom / xamoom-janus / janus / decorators.py View on Github external
return message
            except Exception as e:
                err_msg = ErrorMessage.from_exception(e)
                tb = traceback.format_exc()

                if self.include_traceback_in_errors:
                    if err_msg.meta == None: err_msg.meta = {}
                    err_msg.traceback = tb

                if self.error_hook != None:
                    self.error_hook(int(err_msg.status),err_msg,tb)

                message = JsonApiMessage(errors=err_msg,meta=self.meta).to_json()

                janus_logger.error("Traceback: " + tb)

                return message
github xamoom / xamoom-janus / janus / decorators.py View on Github external
#if it is one return empty array and do nothing else.
                if self.options_hook != None:
                    if self.options_hook() == True:
                        janus_logger.debug("This was an OPTIONS request.")
                        return {}

                response_obj = f(*a, **ka)

                #first check if there is an response object
                #if not nothing to return so HTTP 204
                #otherwise process response
                if response_obj == None:
                    if self.before_send_hook != None:
                        self.before_send_hook(204,None,None)

                    janus_logger.debug("Decorated function returned None. Nothing to map.")
                    return None
                else:
                    #check response object
                    if isinstance(response_obj,JanusResponse) == False:
                        #janus_logger.error("Expected JanusResponse got " + str(type(response_obj)))
                        #raise Exception('Return value has to be instance of JanusResponse')
                        janus_logger.info("Not a JanusResponse. Will return this as it is. No mapping.")
                        return response_obj

                    message = None

                    #caching
                    loaded_from_cache = False

                    if self.cached_get_hook != None:
                        cached_object = self.cached_get_hook(response_obj)
github xamoom / xamoom-janus / janus / janus.py View on Github external
else:
                msg['data'] = self.data.to_dict(do_nesting=self.do_nesting) #set the data object dicts to the message

        if self.errors != None:
            if isinstance(self.errors, (list, tuple)):
                msg['errors'] = [e.to_dict() for e in self.errors]
            else:
                msg['errors'] = [self.errors.to_dict(),]

        if self.included != None: msg['included'] = self.included #if included is present add it to the message

        if self.meta != None: msg['meta'] = self.meta #if meta is present add it to the message

        json_msg = json.loads(json.dumps(msg)) #serialize dict to json and return

        janus_logger.debug("Transformed whole message object to json.")

        return json_msg
github xamoom / xamoom-janus / janus / janus.py View on Github external
self.name = name
            self.required = required
            self.mapping = mapping
            self.read_only = read_only
            self.write_only = write_only
            self.nested = nested
            self.nested_type=nested_type

            if nested == True and nested_type == None:
                janus_logger.error('If nested == True nested_type has to be set.')
                raise Exception('If nested == True nested_type has to be set.')

            if issubclass(value_type,DataMessage): #relationship
                self.key_mapping = key_mapping
        else:
            janus_logger.error('Value Type must be either be a simple type such as ' + str(self.__primitive_types) + ', a subclass of DataMessage or a list or dict containing these types.')
            raise Exception('Value Type must be either be a simple type such as ' + str(self.__primitive_types) + ', a subclass of DataMessage or a list or dict containing these types.')