                 from_date: new XDate(@log_entries.at(0).get('timestamp')*1000).toString("MMMM M, yyyy 'at' HH:mm:ss")
                 to_date: new XDate(@log_entries.at(@log_entries.length-1).get('timestamp')*1000).toString("MMMM M, yyyy 'at' HH:mm:ss")
 
-        fetch_log_entries: (url_params, callback) =>
-            route = "/ajax/log/_?&max_length=#{@max_log_entries * machines.length}"
-
-            for param, value of url_params
-                route+="&#{param}=#{value}"
-
-            $.getJSON route, (log_data_from_server) =>
-                new_log_entries = new LogEntries
-                for machine_uuid, log_entries of log_data_from_server
-                    # Otherwise, keep processing log entry json and prepare to render it
-                    for json in log_entries
-                        entry = new LogEntry json
-                        entry.set('machine_uuid',machine_uuid)
-                        new_log_entries.add entry
-
-                # Don't render anything if there are no new log entries.
-                if new_log_entries.length is 0
-                    @.$('.no-more-entries').show()
-                    @.$('.next-log-entries').hide()
-                    return
-
-                callback(new_log_entries)
 
         destroy: =>
             clearInterval @set_interval

                            , 2000
                )

        render_header: =>
            @.$('.header').html @header_template
                new_entries: @num_new_entries > 0

        className: 'log-view'
        template: Handlebars.compile $('#log-container-template').html()
        header_template: Handlebars.compile $('#log-header-template').html()
        max_log_entries: 10

        current_logs: []
        displayed_logs: 0
        max_timestamp: 0

        log_route: '#logs'

        events: ->
            'click .next-log-entries': 'next_entries'
            'click .update-log-entries': 'update_log_entries'

        initialize: ->
            log_initial '(initializing) events view: container'
            
           #@set_interval = setInterval @check_for_new_updates, updateInterval

        render: =>
            @.$el.html @template({})

            @fetch_log_entries
                max_length: @max_log_entries

            @.delegateEvents()

            return @

        fetch_log_entries: (url_params) =>
            route = "/ajax/log/_?"
            for param, value of url_params
                route+="&#{param}=#{value}"
            
            $.getJSON route, @parse_log
            
        parse_log: (log_data_from_server) =>
            @max_timestamp = 0
            for machine_uuid, log_entries of log_data_from_server

                if log_entries.length > 0
                    @max_timestamp = parseFloat(log_entries[log_entries.length-1].timestamp) if @max_timestamp < parseFloat(log_entries[log_entries.length-1].timestamp)

                last_position = 0
                for json in log_entries # For each new log
                    log_saved = false
                    # Looking if it has been already added
                    for log, i in @current_logs
                        is_same_log = true
                        for attribute of log.attributes
                            if not json.attribute? or log.get(attribute) isnt json.attribute
                                is_same_log = false
                        if is_same_log
                            log_saved = true
                            console.log 'break'
                            break

                    # If it wasn't saved before, look if its place is IN the list 
                    if log_saved is false
                        for log, i in @current_logs
                            if parseFloat(json.timestamp) > parseFloat(log.get('timestamp'))
                                entry = new LogEntry json
                                entry.set('machine_uuid',machine_uuid)
                                @current_logs.splice i, 0, entry
                                log_saved = true
                                break

                    # If it's not, just add it ad the end
                    if log_saved is false
                        entry = new LogEntry json
                        entry.set('machine_uuid',machine_uuid)
                        @current_logs.push entry

            if @current_logs.length <= @displayed_logs
                @.$('.no-more-entries').show()
                @.$('.next-log-entries').hide()
                return
            else
                for i in [0..@max_log_entries-1]
                    if @current_logs[@displayed_logs]?
                        view = new LogView.LogEntry
                            model: @current_logs[@displayed_logs]
                        @.$('.log-entries').append view.render().el
                        @displayed_logs++
                    else
                        @.$('.no-more-entries').show()
                        @.$('.next-log-entries').hide()
 


        next_entries: (event) =>
            event.preventDefault()

            @fetch_log_entries
                max_length: @max_log_entries
                max_timestamp: @max_timestamp

        update_log_entries: (event) =>
            event.preventDefault()
