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