DeepSpace  2019
logging.cpp
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <vector>
4 #include <time.h>
5 #include <unistd.h>
6 
7 std::vector<std::string> buffer;
8 
9 void Log(std::string message){
10  buffer.push_back(message);
11 }
12 
13 void vector_print(std::vector<std::string> const &input)
14 {
15  for (auto const& i: input) {
16  std::cout << i << std::endl;
17  }
18 }
19 
20 void Display(clock_t start, clock_t current){
21  double duration = (double)(current - start) / CLOCKS_PER_SEC;
22  std::cout << "-- " << duration << " seconds since boot --" << std::endl;
24  buffer.clear();
25 }
26 
27 int main(){
28  clock_t start = clock();
29  while(true){
30  clock_t loop = clock();
31  Log("Hello");
32  Log("World");
33 
34  clock_t current = clock();
35  if(buffer.size() > 0){
36  Display(start, current);
37  }
38 
39  // usleep(20 ) ;
40  }
41  return 0;
42 }
bool start
Definition: __main__.py:1094
void vector_print(std::vector< std::string > const &input)
Definition: logging.cpp:13
void Log(std::string message)
Main robot class that is called by wpilib.
Definition: logging.cpp:9
int main()
Definition: logging.cpp:27
std::vector< std::string > buffer
Definition: logging.cpp:7
void Display(clock_t start, clock_t current)
Definition: logging.cpp:20