-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSyslogServer.h
58 lines (46 loc) · 1.05 KB
/
SyslogServer.h
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
//
// Author: Jakub Fajkus
// Project: ISA IRC bot
// Last revision: 17.11.2017
//
#ifndef ISA_SYSLOGSERVER_H
#define ISA_SYSLOGSERVER_H
#include <iostream>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <ctime>
#include <arpa/inet.h>
#include <strings.h>
#include <cstring>
#include <vector>
#include <unistd.h>
#include <err.h>
#define DATE_FORMAT_LENGTH 16 //Mmm dd hh:mm:ss
using namespace std;
class SyslogServer {
private:
int syslog_socket;
struct sockaddr_in syslog_address;
public:
string local_ip;
/**
* Connect to the server with given hostname or IP address
*
* @param server_hostname Hostname or IP address of the syslog server
*/
explicit SyslogServer(string server_hostname);
/**
* Log the given user message
*
* @param user_message
*/
void log(string user_message);
/**
* Close the server socket
*
* @return True, if the socket was successfully closed, false otherwise
*/
bool close_socket();
};
#endif //ISA_SYSLOGSERVER_H