mirror of
				https://github.com/mickael-kerjean/filestash.git
				synced 2025-10-31 10:07:15 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			864 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			864 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { http_get, http_post } from '../helpers/';
 | |
| 
 | |
| class LogManager{
 | |
|     constructor(){}
 | |
| 
 | |
|     get(maxSize = -1){
 | |
|         let url = this.url();
 | |
|         if(maxSize > 0){
 | |
|             url += "?maxSize="+maxSize
 | |
|         }
 | |
|         return http_get(url, 'text');
 | |
|     }
 | |
| 
 | |
|     url(){
 | |
|         return "/admin/api/log";
 | |
|     }
 | |
| 
 | |
|     report(msg, link, lineNo, columnNo, error){
 | |
|         if(navigator.onLine === false) return Promise.resolve();
 | |
|         let url = "/report?";
 | |
|         url += "url="+encodeURIComponent(location.href)+"&";
 | |
|         url += "msg="+encodeURIComponent(msg)+"&";
 | |
|         url += "from="+encodeURIComponent(link)+"&";
 | |
|         url += "from.lineNo="+lineNo+"&";
 | |
|         url += "from.columnNo="+columnNo;
 | |
|         if(error) url += "error="+encodeURIComponent(error.message)+"&";
 | |
|         return http_post(url).catch();
 | |
|     }
 | |
| }
 | |
| 
 | |
| export const Log = new LogManager();
 | 
