SklavaBot 0.1.0
Telegram Bot in C++
Loading...
Searching...
No Matches
utils.cpp
Go to the documentation of this file.
1#include <boost/date_time/c_local_time_adjustor.hpp>
2#include <boost/date_time/local_time_adjustor.hpp>
3#include <boost/date_time/posix_time/posix_time.hpp>
4#include <chrono>
5#include <iostream>
6#include <string>
7
8#include "utils.hpp"
9
10namespace tools {
11
12void flush() {
13 std::cout << "\n" << std::flush;
14 return;
15}
16
17void log_cmd(std::string command, std::string user, std::int32_t timestamp,
18 const std::string log_type) {
19 typedef boost::date_time::c_local_adjustor<boost::posix_time::ptime>
20 local_adj;
21
22 std::string time = boost::posix_time::to_simple_string(
23 local_adj::utc_to_local(boost::posix_time::from_time_t(timestamp)));
24
25 std::cout << log_type << " (" << command << ") "
26 << "sent by @" << user << " -- at " << time;
27
28 flush();
29 return;
30}
31
32} // namespace tools
Definition metar.hpp:6
void log_cmd(std::string command, std::string user, std::int32_t timestamp, const std::string log_type)
Function to print a better log.
Definition utils.cpp:17
void flush()
Flush stdin.
Definition utils.cpp:12