-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotifycli.cpp
59 lines (51 loc) · 2.2 KB
/
notifycli.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
*************************************************************
* @file notifycli.cpp
* @brief Breve descripción
* Pequeña documentación del archivo
*
*
*
*
*
* @author Gaspar Fernández <blakeyed@totaki.com>
* @version
* @date 15 dic 2015
* Historial de cambios:
*
*
*
*
*
*
*
*************************************************************/
#include "notifycli.hpp"
#include <iostream>
#include "lib/timeutils.hpp"
#include "lib/tcolor.hpp"
NotifyCli::NotifyCli(std :: string id):Notify(id, "cli")
{
}
NotifyCli::~NotifyCli()
{
}
void NotifyCli::_newFail(const std :: string & serviceName, std :: chrono :: system_clock :: time_point outageStart, int code, const std :: string &message)
{
std::cout << TColor(TColor::RED) <<"["<<TColor(TColor::LIGHTRED) <<timeformat(outageStart)<<TColor(TColor::RED) <<"] Service "<<serviceName<< " failed with error: "<<message<< "("<<code<<")"<<endColor<<std::endl;
}
void NotifyCli::_newBounce(const std::string& serviceName, uint64_t bounces, std::chrono::system_clock::time_point outageStart, std::chrono::system_clock::time_point outageElapsed, int code, const std::string& message)
{
}
void NotifyCli::_newRecovery(const std :: string & serviceName, std :: chrono :: system_clock :: time_point outageStart, std :: chrono :: system_clock :: time_point outageEnd, int code, const std :: string &message)
{
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(outageEnd - outageStart).count();
std::cout << TColor(TColor::GREEN) << "["<< TColor(TColor::LIGHTGREEN) << timeformat(outageEnd) << TColor(TColor::GREEN) << "] Service "<<serviceName<<" is back to life after "
<< TColor(TColor::GREEN + TColor::UNDERLINE) << itemized_to_str(get_itemized(std::chrono::seconds(elapsed))) << TColor(TColor::GREEN) << endColor << std::endl;
}
void NotifyCli::_newMessage(const std::string& type, const std::string& serviceName, std::chrono::system_clock::time_point outageStart, const std::string& message)
{
std::string strService = (serviceName.empty())?"":"{Service "+serviceName+"}";
std::cout << TColor(TColor::GREEN) << "["<< TColor(TColor::LIGHTGREEN) << timeformat(outageStart) << TColor(TColor::GREEN) << "] ("+type+") "+strService+" Message: "+message
<< endColor << std::endl;
}