logger
							parent
							
								
									a5781aa7ab
								
							
						
					
					
						commit
						9a4844e34c
					
				
							
								
								
									
										19
									
								
								logger.ts
								
								
								
								
							
							
						
						
									
										19
									
								
								logger.ts
								
								
								
								
							|  | @ -1,30 +1,33 @@ | ||||||
| let _loggerdata = "" | let _loggerdata = "" | ||||||
|  | let _log = true | ||||||
| 
 | 
 | ||||||
| // define a new console
 | // define a new console
 | ||||||
| const c=(function(oldCons){ | const c=(function(oldCons){ | ||||||
|     return { |     return { | ||||||
|         log: function(text){ |         log: function(text){ | ||||||
|             oldCons.log(text); |             if (_log) oldCons.log(text) | ||||||
|             if (_loggerdata !== "") _loggerdata += "\n" |             if (_loggerdata !== "") _loggerdata += "\n" | ||||||
|             _loggerdata += text |             _loggerdata += text | ||||||
|         }, |         }, | ||||||
|         info: function (text) { |         info: function (text) { | ||||||
|             oldCons.info(text); |             oldCons.info(text) | ||||||
|         }, |         }, | ||||||
|         warn: function (text) { |         warn: function (text) { | ||||||
|             oldCons.warn(text); |             oldCons.warn(text) | ||||||
|         }, |         }, | ||||||
|         error: function (text) { |         error: function (text) { | ||||||
|             oldCons.error(text); |             oldCons.error(text) | ||||||
|         }, |         }, | ||||||
|         start: function() { |         start: function(log) { | ||||||
|             _loggerdata = "" |             _loggerdata = "" | ||||||
|  |             _log = log | ||||||
|         }, |         }, | ||||||
|         end: function() { |         end: function() { | ||||||
|  |             _log = true | ||||||
|             return _loggerdata |             return _loggerdata | ||||||
|         } |         } | ||||||
|     }; |     } | ||||||
| }(console)); | }(console)) | ||||||
| 
 | 
 | ||||||
| //Then redefine the old console
 | //Then redefine the old console
 | ||||||
| console = c; | console = c | ||||||
		Loading…
	
		Reference in New Issue