hide excessive logging with a trace flag

This commit is contained in:
Jörn Friedrich Dreyer 2013-09-18 14:39:39 +02:00
parent 17337b22af
commit 715846626e
2 changed files with 26 additions and 23 deletions

View file

@ -72,7 +72,7 @@ OC.Upload = {
* cancels all uploads * cancels all uploads
*/ */
cancelUploads:function() { cancelUploads:function() {
console.log('canceling uploads'); this.log('canceling uploads');
jQuery.each(this._uploads,function(i, jqXHR){ jQuery.each(this._uploads,function(i, jqXHR){
jqXHR.abort(); jqXHR.abort();
}); });
@ -135,7 +135,7 @@ OC.Upload = {
* @param data data * @param data data
*/ */
onSkip:function(data){ onSkip:function(data){
this.logStatus('skip', null, data); this.log('skip', null, data);
this.deleteUpload(data); this.deleteUpload(data);
}, },
/** /**
@ -143,7 +143,7 @@ OC.Upload = {
* @param data data * @param data data
*/ */
onReplace:function(data){ onReplace:function(data){
this.logStatus('replace', null, data); this.log('replace', null, data);
data.data.append('resolution', 'replace'); data.data.append('resolution', 'replace');
data.submit(); data.submit();
}, },
@ -152,7 +152,7 @@ OC.Upload = {
* @param data data * @param data data
*/ */
onAutorename:function(data){ onAutorename:function(data){
this.logStatus('autorename', null, data); this.log('autorename', null, data);
if (data.data) { if (data.data) {
data.data.append('resolution', 'autorename'); data.data.append('resolution', 'autorename');
} else { } else {
@ -160,9 +160,12 @@ OC.Upload = {
} }
data.submit(); data.submit();
}, },
logStatus:function(caption, e, data) { _trace:false, //TODO implement log handler for JS per class?
console.log(caption); log:function(caption, e, data) {
console.log(data); if (this._trace) {
console.log(caption);
console.log(data);
}
}, },
/** /**
* TODO checks the list of existing files prior to uploading and shows a simple dialog to choose * TODO checks the list of existing files prior to uploading and shows a simple dialog to choose
@ -207,7 +210,7 @@ $(document).ready(function() {
* @returns {Boolean} * @returns {Boolean}
*/ */
add: function(e, data) { add: function(e, data) {
OC.Upload.logStatus('add', e, data); OC.Upload.log('add', e, data);
var that = $(this); var that = $(this);
// we need to collect all data upload objects before starting the upload so we can check their existence // we need to collect all data upload objects before starting the upload so we can check their existence
@ -300,7 +303,7 @@ $(document).ready(function() {
* @param e * @param e
*/ */
start: function(e) { start: function(e) {
OC.Upload.logStatus('start', e, null); OC.Upload.log('start', e, null);
}, },
submit: function(e, data) { submit: function(e, data) {
OC.Upload.rememberUpload(data); OC.Upload.rememberUpload(data);
@ -313,7 +316,7 @@ $(document).ready(function() {
} }
}, },
fail: function(e, data) { fail: function(e, data) {
OC.Upload.logStatus('fail', e, data); OC.Upload.log('fail', e, data);
if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) { if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) {
if (data.textStatus === 'abort') { if (data.textStatus === 'abort') {
$('#notification').text(t('files', 'Upload cancelled.')); $('#notification').text(t('files', 'Upload cancelled.'));
@ -335,7 +338,7 @@ $(document).ready(function() {
* @param data * @param data
*/ */
done:function(e, data) { done:function(e, data) {
OC.Upload.logStatus('done', e, data); OC.Upload.log('done', e, data);
// handle different responses (json or body from iframe for ie) // handle different responses (json or body from iframe for ie)
var response; var response;
if (typeof data.result === 'string') { if (typeof data.result === 'string') {
@ -373,7 +376,7 @@ $(document).ready(function() {
* @param data * @param data
*/ */
stop: function(e, data) { stop: function(e, data) {
OC.Upload.logStatus('stop', e, data); OC.Upload.log('stop', e, data);
} }
}; };
@ -385,7 +388,7 @@ $(document).ready(function() {
// add progress handlers // add progress handlers
fileupload.on('fileuploadadd', function(e, data) { fileupload.on('fileuploadadd', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadadd', e, data); OC.Upload.log('progress handle fileuploadadd', e, data);
//show cancel button //show cancel button
//if(data.dataType !== 'iframe') { //FIXME when is iframe used? only for ie? //if(data.dataType !== 'iframe') { //FIXME when is iframe used? only for ie?
// $('#uploadprogresswrapper input.stop').show(); // $('#uploadprogresswrapper input.stop').show();
@ -393,29 +396,29 @@ $(document).ready(function() {
}); });
// add progress handlers // add progress handlers
fileupload.on('fileuploadstart', function(e, data) { fileupload.on('fileuploadstart', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadstart', e, data); OC.Upload.log('progress handle fileuploadstart', e, data);
$('#uploadprogresswrapper input.stop').show(); $('#uploadprogresswrapper input.stop').show();
$('#uploadprogressbar').progressbar({value:0}); $('#uploadprogressbar').progressbar({value:0});
$('#uploadprogressbar').fadeIn(); $('#uploadprogressbar').fadeIn();
}); });
fileupload.on('fileuploadprogress', function(e, data) { fileupload.on('fileuploadprogress', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadprogress', e, data); OC.Upload.log('progress handle fileuploadprogress', e, data);
//TODO progressbar in row //TODO progressbar in row
}); });
fileupload.on('fileuploadprogressall', function(e, data) { fileupload.on('fileuploadprogressall', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadprogressall', e, data); OC.Upload.log('progress handle fileuploadprogressall', e, data);
var progress = (data.loaded / data.total) * 100; var progress = (data.loaded / data.total) * 100;
$('#uploadprogressbar').progressbar('value', progress); $('#uploadprogressbar').progressbar('value', progress);
}); });
fileupload.on('fileuploadstop', function(e, data) { fileupload.on('fileuploadstop', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadstop', e, data); OC.Upload.log('progress handle fileuploadstop', e, data);
$('#uploadprogresswrapper input.stop').fadeOut(); $('#uploadprogresswrapper input.stop').fadeOut();
$('#uploadprogressbar').fadeOut(); $('#uploadprogressbar').fadeOut();
}); });
fileupload.on('fileuploadfail', function(e, data) { fileupload.on('fileuploadfail', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadfail', e, data); OC.Upload.log('progress handle fileuploadfail', e, data);
//if user pressed cancel hide upload progress bar and cancel button //if user pressed cancel hide upload progress bar and cancel button
if (data.errorThrown === 'abort') { if (data.errorThrown === 'abort') {
$('#uploadprogresswrapper input.stop').fadeOut(); $('#uploadprogresswrapper input.stop').fadeOut();

View file

@ -652,7 +652,7 @@ $(document).ready(function(){
var file_upload_start = $('#file_upload_start'); var file_upload_start = $('#file_upload_start');
file_upload_start.on('fileuploaddrop', function(e, data) { file_upload_start.on('fileuploaddrop', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploaddrop', e, data); OC.Upload.log('filelist handle fileuploaddrop', e, data);
var dropTarget = $(e.originalEvent.target).closest('tr'); var dropTarget = $(e.originalEvent.target).closest('tr');
if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder
@ -681,7 +681,7 @@ $(document).ready(function(){
}); });
file_upload_start.on('fileuploadadd', function(e, data) { file_upload_start.on('fileuploadadd', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploadadd', e, data); OC.Upload.log('filelist handle fileuploadadd', e, data);
//finish delete if we are uploading a deleted file //finish delete if we are uploading a deleted file
if(FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!==-1){ if(FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!==-1){
@ -715,7 +715,7 @@ $(document).ready(function(){
* update counter when uploading to sub folder * update counter when uploading to sub folder
*/ */
file_upload_start.on('fileuploaddone', function(e, data) { file_upload_start.on('fileuploaddone', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploaddone', e, data); OC.Upload.log('filelist handle fileuploaddone', e, data);
var response; var response;
if (typeof data.result === 'string') { if (typeof data.result === 'string') {
@ -781,7 +781,7 @@ $(document).ready(function(){
} }
}); });
file_upload_start.on('fileuploadstop', function(e, data) { file_upload_start.on('fileuploadstop', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploadstop', e, data); OC.Upload.log('filelist handle fileuploadstop', e, data);
//if user pressed cancel hide upload chrome //if user pressed cancel hide upload chrome
if (data.errorThrown === 'abort') { if (data.errorThrown === 'abort') {
@ -794,7 +794,7 @@ $(document).ready(function(){
} }
}); });
file_upload_start.on('fileuploadfail', function(e, data) { file_upload_start.on('fileuploadfail', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploadfail', e, data); OC.Upload.log('filelist handle fileuploadfail', e, data);
//if user pressed cancel hide upload chrome //if user pressed cancel hide upload chrome
if (data.errorThrown === 'abort') { if (data.errorThrown === 'abort') {