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
20
21namespace openvpn {
22class LogBaseSimple : public LogBase
23{
24 public:
26
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;
44};
45} // namespace openvpn
46
47#endif
virtual void log(const std::string &str) override
RCPtr< LogBaseSimple > Ptr
The smart pointer class.
Definition rc.hpp:119
std::string date_time()
Definition timestr.hpp:139
The logging interface, simple, logs a string.
Scoped RAII for the global_log pointer.
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'