log.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. if(!result.remain){
  26. $('#moreLog').css('display', 'none');
  27. }
  28. }
  29. });
  30. },
  31. addEntries:function(entries){
  32. for(var i=0;i<entries.length;i++){
  33. var entry=entries[i];
  34. var row=$('<tr/>');
  35. var levelTd=$('<td/>');
  36. levelTd.text(OC.Log.levels[entry.level]);
  37. row.append(levelTd);
  38. var appTd=$('<td/>');
  39. appTd.text(entry.app);
  40. row.append(appTd);
  41. var messageTd=$('<td/>');
  42. messageTd.html(entry.message);
  43. row.append(messageTd);
  44. var timeTd=$('<td/>');
  45. timeTd.text(formatDate(entry.time*1000));
  46. row.append(timeTd);
  47. $('#log').append(row);
  48. }
  49. OC.Log.loaded += entries.length;
  50. }
  51. }
  52. $(document).ready(function(){
  53. $('#moreLog').click(function(){
  54. OC.Log.getMore();
  55. })
  56. });