Joedb 10.3.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
diagnostics.cpp
Go to the documentation of this file.
6#include "joedb/ui/type_io.h"
7#include "joedb/get_version.h"
8
9#ifdef JOEDB_HAS_SSH
10#include <libssh/libssh.h>
11#endif
12
13#ifdef JOEDB_HAS_ASIO
14#include <boost/asio/version.hpp>
15#endif
16
17#ifdef JOEDB_HAS_CURL
18#include <curl/curl.h>
19#endif
20
21#ifdef JOEDB_HAS_BROTLI
22#include <brotli/decode.h>
23#include <brotli/encode.h>
24#endif
25
26#include <ostream>
27
28namespace joedb
29{
30 ////////////////////////////////////////////////////////////////////////////
31 void dump_header(std::ostream &out, Abstract_File &file)
32 ////////////////////////////////////////////////////////////////////////////
33 {
34 Header header;
35 file.pread((char *)(&header), Header::size, 0);
36
37 out << " file size: " << file.get_size();
38
39 for (int i = 0; i < 4; i++)
40 out << "\ncheckpoint[" << i << "]: " << header.checkpoint[i];
41
42 out << "\nformat version: " << header.version;
43 out << "\nsignature: ";
45 (
46 out,
47 std::string(header.signature.data(), header.signature.size())
48 );
49 out << '\n';
50 }
51
52 ////////////////////////////////////////////////////////////////////////////
53 void about_joedb(std::ostream &out)
54 ////////////////////////////////////////////////////////////////////////////
55 {
56 out << "joedb version: " << get_version();
57 out << " https://www.joedb.org/\nfile format version: ";
59
60#ifdef JOEDB_HAS_SSH
61 out << "\nlibssh version: " << ssh_version(0) << " https://www.libssh.org/";
62#endif
63
64#ifdef JOEDB_HAS_ASIO
65 out << "\nasio version: ";
66 out << BOOST_ASIO_VERSION / 100000 << '.';
67 out << BOOST_ASIO_VERSION / 100 % 1000 << '.';
68 out << BOOST_ASIO_VERSION % 100;
69 out << " https://think-async.com/Asio/";
70#endif
71
72#ifdef JOEDB_HAS_CURL
73 out << "\ncurl version: " << curl_version();
74#endif
75
76#ifdef JOEDB_HAS_BROTLI
77 out << std::hex;
78 out << "\nbrotli decoder version: " << BrotliDecoderVersion();
79 out << "\nbrotli encoder version: " << BrotliEncoderVersion();
80 out << std::dec;
81#endif
82
83 out << "\ncompiled: " << __DATE__ << ' ' << __TIME__;
84 out << "\n__cplusplus = " << __cplusplus;
85 out << "\nsizeof(bool) = " << sizeof(bool);
86 out << "\nsizeof(size_t) = " << sizeof(size_t);
87 out << "\nsizeof(long) = " << sizeof(long);
88 out << "\nsizeof(std::streamoff) = " << sizeof(std::streamoff);
89#ifdef __unix__
90 out << "\nsizeof(off_t) = " << sizeof(off_t);
91#endif
92 out << "\nFile = " << JOEDB_INCLUDE(JOEDB_FILE, h);
93 out << "\nSystem log = " << JOEDB_INCLUDE(JOEDB_SYSTEM_LOGGER, h);
94#ifdef JOEDB_HAS_BROKEN_POSIX_LOCKING
95 out << "\nbroken_posix_locking = true";
96#else
97 out << "\nbroken_posix_locking = false";
98#endif
99#ifdef _POSIX_SYNCHRONIZED_IO
100 out << "\n_POSIX_SYNCHRONIZED_IO = " << _POSIX_SYNCHRONIZED_IO;
101#endif
102 out << '\n';
103 }
104}
#define JOEDB_INCLUDE(name, extension)
#define JOEDB_SYSTEM_LOGGER
virtual int64_t get_size() const
Get the size of the file, or -1 if it is unknown.
virtual size_t pread(char *data, size_t size, int64_t offset) const
Read a range of bytes.
static constexpr uint32_t format_version
constexpr const char * get_version()
Definition get_version.h:7
void about_joedb(std::ostream &out)
void dump_header(std::ostream &out, Abstract_File &file)
void write_string(std::ostream &out, const std::string &s, bool json)
static constexpr size_t size
Definition Header.h:19
std::array< char, 5 > signature
Definition Header.h:15
uint32_t version
Definition Header.h:14
std::array< int64_t, 4 > checkpoint
Definition Header.h:13