James Kuszmaul | 011b67a | 2019-12-15 12:52:34 -0800 | [diff] [blame] | 1 | #ifndef AOS_LOGGING_LOG_NAMER_H_ |
| 2 | #define AOS_LOGGING_LOG_NAMER_H_ |
| 3 | |
Ravago Jones | 1a4bc76 | 2023-04-09 16:21:57 -0700 | [diff] [blame] | 4 | #include <optional> |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 5 | #include <string> |
James Kuszmaul | 011b67a | 2019-12-15 12:52:34 -0800 | [diff] [blame] | 6 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 7 | namespace aos::logging { |
James Kuszmaul | 011b67a | 2019-12-15 12:52:34 -0800 | [diff] [blame] | 8 | // Returns the correct filename to log to, blocking until the usb drive |
| 9 | // filesystem mounts, incrementing the number on the end of the filename, and |
| 10 | // setting up a symlink at basename-current. |
| 11 | // basename is the prefix to use for the logs within the usb drive. E.g., on a |
| 12 | // typical roborio setup, calling GetLogName("abc") will return a filename of |
| 13 | // the form "/media/sda1/abc-123" and setup a symlink pointing to it at |
| 14 | // "/media/sda1/abc-current". |
| 15 | std::string GetLogName(const char *basename); |
Ravago Jones | 1a4bc76 | 2023-04-09 16:21:57 -0700 | [diff] [blame] | 16 | |
| 17 | // A nonblocking variant of GetLogName that you can poll instead of blocking for |
| 18 | // the usb drive. |
| 19 | std::optional<std::string> MaybeGetLogName(const char *basename); |
| 20 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 21 | } // namespace aos::logging |
James Kuszmaul | 011b67a | 2019-12-15 12:52:34 -0800 | [diff] [blame] | 22 | |
| 23 | #endif // AOS_LOGGING_LOG_NAMER_H_ |