James Kuszmaul | 38735e8 | 2019-12-07 16:42:06 -0800 | [diff] [blame^] | 1 | #include "aos/configuration.h" |
| 2 | #include "aos/events/logging/logger.h" |
| 3 | #include "aos/events/shm_event_loop.h" |
| 4 | #include "aos/init.h" |
| 5 | #include "gflags/gflags.h" |
| 6 | #include "glog/logging.h" |
| 7 | |
| 8 | // TODO(james): Write code for managing logfile names. |
| 9 | DEFINE_string(logfile, "/media/sda1/logfile.bfbs", |
| 10 | "Name of the logfile to write to."); |
| 11 | |
| 12 | DEFINE_string(config, "config.json", "Config file to use."); |
| 13 | |
| 14 | int main(int argc, char *argv[]) { |
| 15 | gflags::SetUsageMessage( |
| 16 | "This program provides a simple logger binary that logs all SHMEM data " |
| 17 | "directly to a file specified at the command line. It does not manage " |
| 18 | "filenames, so it will just crash if you attempt to overwrite an " |
| 19 | "existing file, and the user must specify the logfile manually at the " |
| 20 | "command line."); |
| 21 | aos::InitGoogle(&argc, &argv); |
| 22 | |
| 23 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
| 24 | aos::configuration::ReadConfig(FLAGS_config); |
| 25 | |
| 26 | aos::ShmEventLoop event_loop(&config.message()); |
| 27 | |
| 28 | aos::logger::DetachedBufferWriter writer(FLAGS_logfile); |
| 29 | aos::logger::Logger logger(&writer, &event_loop); |
| 30 | |
| 31 | event_loop.Run(); |
| 32 | |
| 33 | aos::Cleanup(); |
| 34 | return 0; |
| 35 | } |