Eunomia  0.1.0
A lightweight eBPF-based CloudNative Monitor tool for Container Security and Observability
libbpf_print.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2  *
3  * Copyright (c) 2022, 郑昱笙,濮雯旭,张典典(牛校牛子队)
4  * All rights reserved.
5  */
6 
7 #ifndef LIBBPF_PRINT_H
8 #define LIBBPF_PRINT_H
9 
10 #include <bpf/libbpf.h>
11 #include <string>
12 
13 extern bool verbose;
14 
16 static int libbpf_print_fn(enum libbpf_print_level level, const char *format,
17  va_list args) {
18  if (level == LIBBPF_DEBUG && !verbose)
19  return 0;
20  return vfprintf(stderr, format, args);
21 }
22 
24 static std::string get_current_time(void) {
25  struct tm *tm;
26  char ts[32];
27  time_t t;
28 
29  time(&t);
30  tm = localtime(&t);
31  strftime(ts, sizeof(ts), "%H:%M:%S", tm);
32  return std::string(ts);
33 }
34 
35 #endif
verbose
bool verbose
Definition: libbpf_print.cpp:10