Joedb 9.1.4
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 file.set_position(0);
34
35 out << "About this file\n";
36 out << "---------------\n";
37
38 {
39 out << "joedb: ";
40 std::string joedb;
41 for (int i = 5; --i >= 0;)
42 joedb.push_back(char(file.read<uint8_t>()));
43 write_string(out, joedb);
44 out << '\n';
45 }
46
47 {
48 const uint32_t version = file.read<uint32_t>();
49 out << "version: " << version << '\n';
50 }
51
52 {
53 uint64_t pos[4];
54 for (int i = 0; i < 4; i++)
55 pos[i] = file.read<uint64_t>();
56
57 for (int i = 0; i < 4; i++)
58 out << "checkpoint[" << i << "] = " << pos[i] << '\n';
59 }
60
61 out << "file size: " << file.get_size() << '\n';
62 }
63
64 ////////////////////////////////////////////////////////////////////////////
65 void about_joedb(std::ostream &out)
66 ////////////////////////////////////////////////////////////////////////////
67 {
68 out << "About this version of joedb\n";
69 out << "---------------------------\n";
70 out << "joedb version: " << get_version() << '\n';
71 out << "Writable_Journal::compatible_version: ";
73 out << "Writable_Journal::version_number: ";
75
76#ifdef JOEDB_HAS_SSH
77 out << "libssh version: " << ssh_version(0) << " https://www.libssh.org/\n";
78#endif
79
80#ifdef JOEDB_HAS_ASIO
81 out << "asio version: ";
82 out << ASIO_VERSION / 100000 << '.';
83 out << ASIO_VERSION / 100 % 1000 << '.';
84 out << ASIO_VERSION % 100;
85 out << " https://think-async.com/Asio/\n";
86#endif
87
88#ifdef JOEDB_HAS_CURL
89 out << "curl version: " << curl_version() << '\n';
90#endif
91
92#ifdef JOEDB_HAS_BROTLI
93 out << std::hex;
94 out << "brotli decoder version: " << BrotliDecoderVersion() << '\n';
95 out << "brotli encoder version: " << BrotliEncoderVersion() << '\n';
96 out << std::dec;
97#endif
98
99 out << "compiled: " << __DATE__ << ' ' << __TIME__ << '\n';
100 out << "sizeof(size_t) = " << sizeof(size_t) << '\n';
101 out << "sizeof(long) = " << sizeof(long) << '\n';
102 out << "sizeof(std::streamoff) = " << sizeof(std::streamoff) << '\n';
103#ifdef __unix__
104 out << "sizeof(off_t) = " << sizeof(off_t) << '\n';
105#endif
106 out << "File = " << JOEDB_INCLUDE(JOEDB_FILE, h) << '\n';
107 out << "broken_posix_locking = ";
108#ifdef JOEDB_HAS_BROKEN_POSIX_LOCKING
109 out << 1;
110#else
111 out << 0;
112#endif
113 out << '\n';
114 out << "web site: https://www.joedb.org/\n";
115 }
116}
#define JOEDB_INCLUDE(name, extension)
Definition File.h:19
virtual int64_t get_size() const
void set_position(int64_t position)
static constexpr uint32_t version_number
static constexpr uint32_t compatible_version
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
constexpr const char * get_version()
Definition get_version.h:6