log.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Copyright (c) 2012, Robin Appelman <icewind1991@gmail.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. OC.Log={
  7. reload:function(count){
  8. if(!count){
  9. count=OC.Log.loaded;
  10. }
  11. OC.Log.loaded=0;
  12. $('#log tbody').empty();
  13. OC.Log.getMore(count);
  14. },
  15. levels:['Debug','Info','Warning','Error','Fatal'],
  16. loaded:3,//are initially loaded
  17. getMore:function(count){
  18. if(!count){
  19. count=10;
  20. }
  21. $.get(OC.filePath('settings','ajax','getlog.php'),{offset:OC.Log.loaded,count:count},function(result){
  22. if(result.status=='success'){
  23. OC.Log.addEntries(result.data);
  24. $('html, body').animate({scrollTop: $(document).height()}, 800);
  25. }
  26. });
  27. },
  28. addEntries:function(entries){
  29. for(var i=0;i<entries.length;i++){
  30. var entry=entries[i];
  31. var row=$('<tr/>');
  32. var levelTd=$('<td/>');
  33. levelTd.text(OC.Log.levels[entry.level]);
  34. row.append(levelTd);
  35. var appTd=$('<td/>');
  36. appTd.text(entry.app);
  37. row.append(appTd);
  38. var messageTd=$('<td/>');
  39. messageTd.text(entry.message);
  40. row.append(messageTd);
  41. var timeTd=$('<td/>');
  42. timeTd.text(formatDate(entry.time*1000));
  43. row.append(timeTd);
  44. $('#log').append(row);
  45. }
  46. OC.Log.loaded += entries.length;
  47. }
  48. }
  49. $(document).ready(function(){
  50. $('#moreLog').click(function(){
  51. OC.Log.getMore();
  52. })
  53. });