OpenVPN 3 Core Library
Loading...
Searching...
No Matches
logbasesimple.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
#ifndef OPENVPN_LOG_LOGBASESIMPLE_H
13
#define OPENVPN_LOG_LOGBASESIMPLE_H
14
15
#include <iostream>
16
#include <mutex>
17
18
#include <
openvpn/log/logbase.hpp
>
19
#include <
openvpn/time/timestr.hpp
>
20
21
namespace
openvpn
{
22
class
LogBaseSimple
:
public
LogBase
23
{
24
public
:
25
typedef
RCPtr<LogBaseSimple>
Ptr
;
26
27
LogBaseSimple
()
28
:
log_context
(this)
29
{
30
}
31
32
virtual
void
log
(
const
std::string &
str
)
override
33
{
34
const
std::string ts =
date_time
();
35
{
36
std::lock_guard<std::mutex> lock(
mutex
);
37
std::cout << ts <<
' '
<<
str
<< std::flush;
38
}
39
}
40
41
private
:
42
std::mutex
mutex
;
43
Log::Context
log_context
;
44
};
45
}
// namespace openvpn
46
47
#endif
openvpn::LogBaseSimple
Definition
logbasesimple.hpp:23
openvpn::LogBaseSimple::LogBaseSimple
LogBaseSimple()
Definition
logbasesimple.hpp:27
openvpn::LogBaseSimple::log_context
Log::Context log_context
Definition
logbasesimple.hpp:43
openvpn::LogBaseSimple::log
virtual void log(const std::string &str) override
Definition
logbasesimple.hpp:32
openvpn::LogBaseSimple::mutex
std::mutex mutex
Definition
logbasesimple.hpp:42
openvpn::LogBaseSimple::Ptr
RCPtr< LogBaseSimple > Ptr
Definition
logbasesimple.hpp:25
openvpn::RCPtr
The smart pointer class.
Definition
rc.hpp:119
logbase.hpp
openvpn
Definition
ovpncli.cpp:97
openvpn::date_time
std::string date_time()
Definition
timestr.hpp:139
openvpn::LogBase
The logging interface, simple, logs a string.
Definition
logbase_class.hpp:26
openvpn::Log::Context
Scoped RAII for the global_log pointer.
Definition
logdatetime.hpp:33
str
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'
timestr.hpp
openvpn
log
logbasesimple.hpp
Generated by
1.9.8