Limit log to 5000 lines
This commit is contained in:
parent
c1674e9d76
commit
3862dd163d
|
@ -17,6 +17,10 @@ require 'travis/model'
|
|||
@addObserver 'body', @fetchWorker
|
||||
@fetchWorker()
|
||||
|
||||
id: (->
|
||||
@get('job.id')
|
||||
).property('job.id')
|
||||
|
||||
clear: ->
|
||||
@set('body', '')
|
||||
@incrementProperty('version')
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
target.closest('.fold').toggleClass('open')
|
||||
|
||||
if target.is('a') && target.attr('id').match(/^L\d+$/)
|
||||
if target.is('a') && target.attr('id') && target.attr('id').match(/^L\d+$/)
|
||||
path = target.attr 'href'
|
||||
Travis.app.get('router').route(path)
|
||||
event.stopPropagation()
|
||||
|
@ -173,6 +173,7 @@
|
|||
url = @get('logUrl')
|
||||
|
||||
leftOut = []
|
||||
cut = false
|
||||
fragment = document.createDocumentFragment()
|
||||
|
||||
# TODO: refactor this loop, it's getting messy
|
||||
|
@ -180,54 +181,60 @@
|
|||
line = payload.content
|
||||
number = payload.number
|
||||
|
||||
unless payload.append
|
||||
pathWithNumber = "#{url}#L#{number}"
|
||||
p = document.createElement('p')
|
||||
p.innerHTML = "<a href=\"#{pathWithNumber}\" id=\"L#{number}\">#{number}</a>#{line}"
|
||||
line = p
|
||||
|
||||
if payload.fold && !payload.foldContinuation
|
||||
div = document.createElement('div')
|
||||
div.appendChild line
|
||||
div.className = "fold #{payload.fold} show-first-line"
|
||||
line = div
|
||||
|
||||
if payload.replace
|
||||
if link = fragment.querySelector("#L#{number}")
|
||||
link.parentElement.innerHTML = line.innerHTML
|
||||
else
|
||||
this.$("#L#{number}").parent().replaceWith line
|
||||
else if payload.append
|
||||
if link = fragment.querySelector("#L#{number}")
|
||||
link.parentElement.innerHTML += line
|
||||
else
|
||||
this.$("#L#{number}").parent().append line
|
||||
else if payload.foldContinuation
|
||||
folds = fragment.querySelectorAll(".fold.#{payload.fold}")
|
||||
if fold = folds[folds.length - 1]
|
||||
fold.appendChild line
|
||||
else
|
||||
this.$("#log .fold.#{payload.fold}:last").append line
|
||||
if payload.logWasCut
|
||||
cut = true
|
||||
else
|
||||
fragment.appendChild(line)
|
||||
unless payload.append
|
||||
pathWithNumber = "#{url}#L#{number}"
|
||||
p = document.createElement('p')
|
||||
p.innerHTML = "<a href=\"#{pathWithNumber}\" id=\"L#{number}\">#{number}</a>#{line}"
|
||||
line = p
|
||||
|
||||
if payload.openFold
|
||||
folds = fragment.querySelectorAll(".fold.#{payload.fold}")
|
||||
if fold = folds[folds.length - 1]
|
||||
fold = $(fold)
|
||||
if payload.fold && !payload.foldContinuation
|
||||
div = document.createElement('div')
|
||||
div.appendChild line
|
||||
div.className = "fold #{payload.fold} show-first-line"
|
||||
line = div
|
||||
|
||||
if payload.replace
|
||||
if link = fragment.querySelector("#L#{number}")
|
||||
link.parentElement.innerHTML = line.innerHTML
|
||||
else
|
||||
this.$("#L#{number}").parent().replaceWith line
|
||||
else if payload.append
|
||||
if link = fragment.querySelector("#L#{number}")
|
||||
link.parentElement.innerHTML += line
|
||||
else
|
||||
this.$("#L#{number}").parent().append line
|
||||
else if payload.foldContinuation
|
||||
folds = fragment.querySelectorAll(".fold.#{payload.fold}")
|
||||
if fold = folds[folds.length - 1]
|
||||
fold.appendChild line
|
||||
else
|
||||
this.$("#log .fold.#{payload.fold}:last").append line
|
||||
else
|
||||
fold = this.$(".fold.#{payload.fold}:last")
|
||||
fragment.appendChild(line)
|
||||
|
||||
fold.removeClass('show-first-line').addClass('open')
|
||||
if payload.openFold
|
||||
folds = fragment.querySelectorAll(".fold.#{payload.fold}")
|
||||
if fold = folds[folds.length - 1]
|
||||
fold = $(fold)
|
||||
else
|
||||
fold = this.$(".fold.#{payload.fold}:last")
|
||||
|
||||
if payload.foldEnd
|
||||
folds = fragment.querySelectorAll(".fold.#{payload.fold}")
|
||||
if fold = folds[folds.length - 1]
|
||||
fold = $(fold)
|
||||
else
|
||||
fold = this.$(".fold.#{payload.fold}:last")
|
||||
fold.removeClass('show-first-line').addClass('open')
|
||||
|
||||
fold.removeClass('show-first-line')
|
||||
if payload.foldEnd
|
||||
folds = fragment.querySelectorAll(".fold.#{payload.fold}")
|
||||
if fold = folds[folds.length - 1]
|
||||
fold = $(fold)
|
||||
else
|
||||
fold = this.$(".fold.#{payload.fold}:last")
|
||||
|
||||
fold.removeClass('show-first-line')
|
||||
|
||||
this.$('#log')[0].appendChild fragment
|
||||
if cut
|
||||
url = Travis.Urls.plainTextLog(@get('log.id'))
|
||||
this.$("#log").append $("<p class=\"cut\">Log was too long to display. Download the <a href=\"#{url}\">the raw version</a> to get the full log.</p>")
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ FOLDS = [
|
|||
init: ->
|
||||
@set 'folds', []
|
||||
@set 'line', 1
|
||||
@set 'lineNumber', 1
|
||||
@initial = true
|
||||
|
||||
for fold in FOLDS
|
||||
|
@ -16,6 +17,7 @@ FOLDS = [
|
|||
|
||||
append: (lines) ->
|
||||
return unless lines
|
||||
return if @get('lineNumber') > 5000
|
||||
|
||||
log = @join lines
|
||||
log = @escape log
|
||||
|
@ -26,8 +28,6 @@ FOLDS = [
|
|||
index = 0
|
||||
currentFold = @currentFold
|
||||
|
||||
@set 'lineNumber', 1 unless @get 'lineNumber'
|
||||
|
||||
result = []
|
||||
|
||||
for line in lines
|
||||
|
@ -88,6 +88,10 @@ FOLDS = [
|
|||
if currentFold
|
||||
@set 'foldContinuation', true
|
||||
|
||||
if @get('lineNumber') + index >= 5000
|
||||
result.pushObject logWasCut: true
|
||||
break
|
||||
|
||||
if result.length > 0
|
||||
if currentFold
|
||||
@currentFold = currentFold
|
||||
|
|
|
@ -3,6 +3,7 @@ $font-size-big: 15px
|
|||
$font-size-normal: 13px
|
||||
$font-size-small: 12px
|
||||
$font-size-log: 12px
|
||||
$font-size-log-bigger: 13px
|
||||
$font-size-smaller: 12px
|
||||
$font-size-tiny: 11px
|
||||
$font-size-tiniest: 10px
|
||||
|
|
|
@ -18,6 +18,14 @@ pre#log
|
|||
@include border-radius(4px)
|
||||
overflow-x: scroll
|
||||
|
||||
p.cut
|
||||
margin-top: 15px
|
||||
&:hover
|
||||
background-color: transparent
|
||||
&.highlight
|
||||
background-color: transparent
|
||||
a
|
||||
margin: 0
|
||||
p
|
||||
padding: 0 15px 0 50px
|
||||
margin: 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user