| Tim Windelschmidt | 6d33a43 | 2025-02-04 14:34:25 +0100 | [diff] [blame^] | 1 | // Copyright The Monogon Project Authors. |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| Serge Bazanski | 05f813b | 2023-03-16 17:58:39 +0100 | [diff] [blame] | 4 | package launch |
| 5 | |
| 6 | import ( |
| 7 | "fmt" |
| 8 | "os" |
| 9 | "strings" |
| 10 | ) |
| 11 | |
| 12 | // Log is compatible with the output of ConciseString as used in the Metropolis |
| 13 | // console log, making the output more readable in unified test logs. |
| 14 | func Log(f string, args ...any) { |
| 15 | formatted := fmt.Sprintf(f, args...) |
| 16 | for i, line := range strings.Split(formatted, "\n") { |
| 17 | if len(line) == 0 { |
| 18 | continue |
| 19 | } |
| 20 | if i == 0 { |
| 21 | fmt.Printf("TT| %20s ! %s\n", "test launch", line) |
| 22 | } else { |
| 23 | fmt.Printf("TT| %20s | %s\n", "", line) |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | func Fatal(f string, args ...any) { |
| 29 | Log(f, args...) |
| 30 | os.Exit(1) |
| 31 | } |