| 
									
										
										
										
											2021-08-21 23:26:03 +00:00
										 |  |  | import * as core from '@actions/core'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 18:27:04 +00:00
										 |  |  | class CloudRunnerLogger { | 
					
						
							| 
									
										
										
										
											2021-08-21 23:26:03 +00:00
										 |  |  |   private static timestamp: number; | 
					
						
							|  |  |  |   private static globalTimestamp: number; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public static setup() { | 
					
						
							|  |  |  |     this.timestamp = this.createTimestamp(); | 
					
						
							|  |  |  |     this.globalTimestamp = this.timestamp; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 18:27:04 +00:00
										 |  |  |   public static log(message: string) { | 
					
						
							|  |  |  |     core.info(message); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-26 19:24:10 +00:00
										 |  |  |   public static logCli(message: string) { | 
					
						
							| 
									
										
										
										
											2021-12-26 18:48:09 +00:00
										 |  |  |     CloudRunnerLogger.log(`[CLI] ${message}`); | 
					
						
							| 
									
										
										
										
											2021-12-24 04:05:42 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-19 01:45:55 +00:00
										 |  |  |   public static logLine(message: string) { | 
					
						
							|  |  |  |     core.info(`${message}\n`); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 18:27:04 +00:00
										 |  |  |   public static error(message: string) { | 
					
						
							|  |  |  |     core.error(message); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-21 23:26:03 +00:00
										 |  |  |   public static logWithTime(message: string) { | 
					
						
							|  |  |  |     const newTimestamp = this.createTimestamp(); | 
					
						
							|  |  |  |     core.info( | 
					
						
							|  |  |  |       `${message} (Since previous: ${this.calculateTimeDiff( | 
					
						
							|  |  |  |         newTimestamp, | 
					
						
							|  |  |  |         this.timestamp, | 
					
						
							|  |  |  |       )}, Total time: ${this.calculateTimeDiff(newTimestamp, this.globalTimestamp)})`,
 | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     this.timestamp = newTimestamp; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   private static calculateTimeDiff(x: number, y: number) { | 
					
						
							|  |  |  |     return Math.floor((x - y) / 1000); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   private static createTimestamp() { | 
					
						
							|  |  |  |     return Date.now(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-09-21 18:27:04 +00:00
										 |  |  | export default CloudRunnerLogger; |