make LogFile nicer, move stuff around
							parent
							
								
									beff30babf
								
							
						
					
					
						commit
						6f4326502c
					
				| @ -0,0 +1,33 @@ | ||||
| package alfred.web.core | ||||
| 
 | ||||
| import java.io.File | ||||
| import java.nio.file.Path | ||||
| import java.time.ZonedDateTime | ||||
| import kotlin.io.appendText | ||||
| 
 | ||||
| class LogFile( | ||||
|     val backingFile: File | ||||
| ) { | ||||
| 
 | ||||
|     fun header(buildId: BuildId, rev: String, workspace: Path) { | ||||
|         append("At your service.") | ||||
|         append("Build $buildId, rev [$rev] started at ${ZonedDateTime.now()}") | ||||
|         append("Workspace directory is: $workspace\n") | ||||
|     } | ||||
| 
 | ||||
|     fun footer() { | ||||
|         append("Build finished at ${ZonedDateTime.now()}") | ||||
|     } | ||||
| 
 | ||||
|     fun append(content: String) = | ||||
|         backingFile.appendText( | ||||
|             content.lines().joinToString(separator = "\n") { | ||||
|                 if (it.trim().isEmpty()) { | ||||
|                     "" | ||||
|                 } else { | ||||
|                     "Alfred: $it" | ||||
|                 } | ||||
|             } + "\n" | ||||
|         ) | ||||
| 
 | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue
	
	 Josha von Gizycki
						Josha von Gizycki