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