Esempio n. 1
0
    def createFromNodeJs(self, data):
        if not self._validateNodeJsData(data):
            return False

        self._populateFromNodeJs(data)
        Debugger.log("Storing request data to Database...", 'debug')
        db = Database()

        # Storing main table
        query = "INSERT INTO requests (id, datetime, url, memory, stats, get, post, server, level, read)" \
                " VALUES (NULL, ?,?,?,?,?,?,?,?,0)"
        bind = (self._datetime, self._url, self._memory, JSON.encode(self._stats), JSON.encode(self._get),
                JSON.encode(self._post), JSON.encode(self._server), self._level)
        db.execute(query, bind)
        self._id = db.last_inserted_id

        # Storing messages
        messages = self._messages
        self._messages = []
        for message in messages:
            m = Message()
            message['request'] = self._id
            m.createFromNodeJs(message)
            self._messages.append(m)

        """
        Modify data (this will also affect the Request table model)
        """
        settings = Settings()
        if Request._RECORDS is not None:
            Request._RECORDS.insert(0, self)
            if len(Request._RECORDS) > settings.requests_limit:
                del Request._RECORDS[-1]

        return True
Esempio n. 2
0
 def save(self):
     db = Database()
     for i in Settings._SETTINGS.items():
         key = i[0]
         value = i[1]
         if key == 'log_levels':
             value = JSON.encode(value)
         query = "UPDATE settings SET value = ? WHERE key = ?"
         db.execute(query, (value, key))
Esempio n. 3
0
    def createFromNodeJs(self, data):
        if not self._validateNodeJsData(data):
            return False

        self._populateFromNodeJs(data)
        Debugger.log("Storing message data to Database...", 'debug')
        db = Database()

        # Storing main table
        query = "INSERT INTO messages (`group`, message, file, line, memory, level, datetime, context, extra, request) " \
                "VALUES (?,?,?,?,?,?,?,?,?,?)"
        bind = (
            self._group, self._message, self._file, self._line, self._memory, self._level, self._datetime, JSON.encode(self._context),
            JSON.encode(self._extra), self._request)
        db.execute(query, bind)
        self._id = db.last_inserted_id
        return True