27#include "TApplication.h"
44#include <mysqld_error.h>
48#include <mysqld_error.h>
66 const char*
sign =
"";
98#define CHN_TREE_STR(_name) const char *_name[] = {\
101"Type = STRING : [8] Disk",\
102"Filename = STRING : [256] run%05d.mid",\
103"Format = STRING : [8] MIDAS",\
104"Compression = INT32 : 0",\
105"ODB dump = BOOL : 1",\
106"ODB dump format = STRING : [32] json",\
107"Options ODB dump format = STRING[3] :",\
111"Log messages = UINT32 : 0",\
112"Buffer = STRING : [32] SYSTEM",\
113"Event ID = INT32 : -1",\
114"Trigger mask = INT32 : -1",\
115"Event limit = DOUBLE : 0",\
116"Byte limit = DOUBLE : 0",\
117"Subrun Byte limit = DOUBLE : 0",\
118"Tape capacity = DOUBLE : 0",\
119"Subdir format = STRING : [32]",\
120"Current filename = STRING : [256]",\
121"Data checksum = STRING : [256] CRC32C",\
122"Options Data checksum = STRING[5] :",\
128"File checksum = STRING : [256] CRC32C",\
129"Options File checksum = STRING[5] :",\
135"Compress = STRING : [256] lz4",\
136"Options Compress = STRING[5] :",\
142"Output = STRING : [256] FILE",\
143"Options Output = STRING[5] :",\
149"Gzip compression = UINT32 : 0",\
150"Bzip2 compression = UINT32 : 0",\
151"Pbzip2 num cpu = UINT32 : 0",\
152"Pbzip2 compression = UINT32 : 0",\
153"Pbzip2 options = STRING : [256]",\
156"Events written = DOUBLE : 0",\
157"Bytes written = DOUBLE : 0",\
158"Bytes written uncompressed = DOUBLE : 0",\
159"Bytes written total = DOUBLE : 0",\
160"Bytes written subrun = DOUBLE : 0",\
161"Files written = DOUBLE : 0",\
162"Disk level = DOUBLE : 0",\
168 char obsolete_type[8];
170 char obsolete_format[8];
173 char odb_dump_format[32];
174 char options_odb_dump_format[3][32];
183 char subdir_format[32];
184 char current_filename[256];
185 char data_checksum[256];
186 char options_data_checksum[5][32];
187 char file_checksum[256];
188 char options_file_checksum[5][32];
190 char options_compress[5][32];
192 char options_output[5][32];
197 char pbzip2_options[256];
202#define CHN_SETTINGS_STR(_name) const char *_name[] = { \
204"Type = STRING : [8] Disk",\
205"Filename = STRING : [256] run%05d.mid",\
206"Format = STRING : [8] MIDAS",\
207"Compression = INT32 : 0",\
208"ODB dump = BOOL : 1",\
209"ODB dump format = STRING : [32] json",\
210"Log messages = UINT32 : 0",\
211"Buffer = STRING : [32] SYSTEM",\
212"Event ID = INT32 : -1",\
213"Trigger mask = INT32 : -1",\
214"Event limit = DOUBLE : 0",\
215"Byte limit = DOUBLE : 0",\
216"Subrun Byte limit = DOUBLE : 0",\
217"Tape capacity = DOUBLE : 0",\
218"Subdir format = STRING : [32]",\
219"Current filename = STRING : [256]",\
220"Data checksum = STRING : [256]",\
221"File checksum = STRING : [256]",\
222"Compress = STRING : [256]",\
223"Output = STRING : [256]",\
224"Gzip compression = UINT32 : 0",\
225"Bzip2 compression = UINT32 : 0",\
226"Pbzip2 num cpu = UINT32 : 0",\
227"Pbzip2 compression = UINT32 : 0",\
228"Pbzip2 options = STRING : [256]",\
242#define CHN_STATISTICS_STR(_name) const char *_name[] = {\
243"Events written = DOUBLE : 0",\
244"Bytes written = DOUBLE : 0",\
245"Bytes written uncompressed = DOUBLE : 0",\
246"Bytes written total = DOUBLE : 0",\
247"Bytes written subrun = DOUBLE : 0",\
248"Files written = DOUBLE : 0",\
249"Disk level = DOUBLE : 0",\
310#define DISK_CHECK_INTERVAL_MILLISEC 10000
365#define MEMZERO(obj) memset(&(obj), 0, sizeof(obj))
367#define FREE(ptr) if (ptr) free(ptr); (ptr)=NULL;
368#define DELETE(ptr) if (ptr) delete (ptr); (ptr)=NULL;
374 std::string path =
xpath;
376 size_t p = path.rfind(
".");
378 if (p == std::string::npos)
380 path = path.substr(0, p);
430 printf(
"WriterInterface: default constructor!\n");
448 printf(
"WriterNull: destructor\n");
454 printf(
"WriterNull: open path [%s]\n",
log_chn->path.c_str());
466 printf(
"WriterNull: write path [%s], size %d\n",
log_chn->path.c_str(), size);
478 printf(
"WriterNull: close path [%s]\n",
log_chn->path.c_str());
514 printf(
"WriterFile: destructor\n");
524 printf(
"WriterFile: open path [%s]\n",
log_chn->path.c_str());
550 printf(
"WriterFile: write path [%s], size %d\n",
log_chn->path.c_str(), size);
577 printf(
"WriterFile: close path [%s]\n",
log_chn->path.c_str());
616 if (
log_chn->settings.gzip_compression) {
627 printf(
"WriterGzip: destructor\n");
639 printf(
"WriterGzip: open path [%s]\n",
log_chn->path.c_str());
664#if ZLIB_VERNUM > 0x1235
672#warning Very old zlib, no gzbuffer()!
684 printf(
"WriterGzip: write path [%s], size %d\n",
log_chn->path.c_str(), size);
700#if ZLIB_VERNUM > 0x1235
704#warning Very old zlib, no gzoffset()!
720 printf(
"WriterGzip: close path [%s]\n",
log_chn->path.c_str());
781 printf(
"WriterPopen: destructor\n");
821 printf(
"WriterPopen: write path [%s], size %d\n",
log_chn->path.c_str(), size);
841 cm_msg(
MERROR,
"WriterPopen::wr_write",
"Cannot write to pipe \'%s\': broken pipe, closing the pipe",
fCommand.c_str());
862 printf(
"WriterPopen: close path [%s]\n",
log_chn->path.c_str());
928 printf(
"WriterCRC32Zlib: destructor\n");
958 printf(
"WriterCRC32Zlib: write path [%s], size %d\n",
log_chn->path.c_str(), size);
977 std::string f = x +
".crc32zlib";
980 printf(
"WriterCRC32Zlib: close path [%s], level %d, file [%s]\n",
log_chn->path.c_str(),
fLevel, f.c_str());
984 cm_msg(
MLOG,
"CRC32Zlib",
"File \'%s\' CRC32-zlib checksum: 0x%08lx, %.0f bytes", x.c_str(), (
unsigned long)
fCrc32,
fBytesIn);
1044 printf(
"WriterCRC32C: destructor\n");
1074 printf(
"WriterCRC32C: write path [%s], size %d\n",
log_chn->path.c_str(), size);
1093 std::string f = x +
".crc32c";
1096 printf(
"WriterCRC32C: close path [%s], level %d, file [%s]\n",
log_chn->path.c_str(),
fLevel, f.c_str());
1100 cm_msg(
MLOG,
"CRC32C",
"File \'%s\' CRC32C checksum: 0x%08lx, %.0f bytes", x.c_str(), (
unsigned long)
fCrc32,
fBytesIn);
1161 printf(
"WriterSHA256: destructor\n");
1193 printf(
"WriterSHA256: write path [%s], size %d\n",
log_chn->path.c_str(), size);
1219 for (
int i=0;
i<32;
i++)
1227 std::string f = x +
".sha256";
1230 printf(
"WriterSHA256: close path [%s], level %d, file [%s]\n",
log_chn->path.c_str(),
fLevel, f.c_str());
1244 cm_msg(
MERROR,
"WriterSHA256::wr_close",
"Cannot write SHA-256 checksum to file \'%s\', fopen() errno %d (%s)", f.c_str(),
errno,
strerror(
errno));
1301 printf(
"WriterSHA512: destructor\n");
1333 printf(
"WriterSHA512: write path [%s], size %d\n",
log_chn->path.c_str(), size);
1359 for (
int i=0;
i<64;
i++)
1367 std::string f = x +
".sha512";
1370 printf(
"WriterSHA512: close path [%s], level %d, file [%s]\n",
log_chn->path.c_str(),
fLevel, f.c_str());
1384 cm_msg(
MERROR,
"WriterSHA512::wr_close",
"Cannot write SHA-512 checksum to file \'%s\', fopen() errno %d (%s)", f.c_str(),
errno,
strerror(
errno));
1420#include "mlz4frame.h"
1441 printf(
"WriterLZ4: destructor\n");
1453 printf(
"WriterLZ4: open path [%s]\n",
log_chn->path.c_str());
1478 fPrefs.compressionLevel = 0;
1507 const char* ptr = (
const char*)
data;
1511 printf(
"WriterLZ4: write path [%s], size %d\n",
log_chn->path.c_str(), size);
1523 cm_msg(
MERROR,
"WriterLZ4::wr_write",
"LZ4F_compressUpdate() with %d bytes, block size %d, buffer size %d, write size %d, remaining %d bytes, error %d (%s)",
wsize,
fBlockSize,
fBufferSize, size,
remaining, (
int)
errorCode,
MLZ4F_getErrorName(
errorCode));
1551 printf(
"WriterLZ4: close path [%s]\n",
log_chn->path.c_str());
1640 size =
sizeof(
BOOL);
1647 str =
"run%05d.json";
1654 size =
sizeof(
BOOL);
1670 cm_msg(
MERROR,
"logger_init",
"Cannot create channel entry in database");
1702 static int buffer_size = 100000;
1706 if (pevent ==
NULL) {
1707 cm_msg(
MERROR,
"log_odb_dump",
"Cannot allocate ODB dump buffer");
1731 static int buffer_size = 100000;
1735 if (pevent ==
NULL) {
1736 cm_msg(
MERROR,
"log_odb_dump",
"Cannot allocate ODB dump buffer");
1762 char* buffer =
NULL;
1763 int buffer_size = 0;
1773 if (pevent ==
NULL) {
1794 cm_msg(
MERROR,
"log_odb_dump",
"Invalid ODB dump format \"%s\" in ODB settings for channel \"%s\". Valid formats are: \"odb\", \"xml\", \"json\"",
log_chn->settings.odb_dump_format,
log_chn->name.c_str());
1806 if (path.length() > 0) {
1828 chmod(path.c_str(), 0444);
1833 printf(
"saved odb to \"%s\" in %d ms\n", path.c_str(),
te-
t0);
1839static void xwrite(
const char* filename,
int fd,
const void*
data,
int size)
1857static const char *
mname[] = {
1881 for (
i = 0;
i < 12;
i++)
1893 if (
tms.tm_year < 90)
1898 tms.tm_year + 1900,
tms.tm_mon + 1,
tms.tm_mday,
tms.tm_hour,
tms.tm_min,
tms.tm_sec);
1906 std::string filename;
1917 if (!filename.empty()) {
1926 path = dir + filename;
1933 path = dir + filename;
1938 printf(
"Cannot open message log file \'%s\', open() returned %d, errno %d (%s)\n", path.c_str(),
1942 xwrite(path.c_str(),
fh,
";\n", 2);
1977 for (
i = 0;
i <
n;
i++) {
2007 strcpy(
str,
"DATETIME");
2017 strcpy(
str,
"TINYINT UNSIGNED ");
2020 strcpy(
str,
"TINYINT ");
2023 strcpy(
str,
"CHAR ");
2026 strcpy(
str,
"SMALLINT UNSIGNED ");
2029 strcpy(
str,
"SMALLINT ");
2032 strcpy(
str,
"INT UNSIGNED ");
2035 strcpy(
str,
"INT ");
2038 strcpy(
str,
"BOOLEAN ");
2041 strcpy(
str,
"FLOAT ");
2044 strcpy(
str,
"DOUBLE ");
2069 cm_msg(
MERROR,
"sql_create_database",
"ODB tree \"%s\" contains no variables", path.c_str());
2097 cm_msg(
MERROR,
"sql_modify_table",
"ODB tree \"%s\" contains no variables", path.c_str());
2108 query =
msprintf(
"ALTER TABLE `%s`.`%s` ADD `%s` %s AFTER `%s`",
2182 query +=
") VALUES (";
2295 char hostname[80], username[80], password[80], table[80], filename[80];
2307 size =
sizeof(hostname);
2308 strcpy(hostname,
"localhost");
2311 size =
sizeof(username);
2312 strcpy(username,
"root");
2315 size =
sizeof(password);
2324 size =
sizeof(table);
2325 strcpy(table,
"Runlog");
2328 size =
sizeof(filename);
2329 strcpy(filename,
"sql.log");
2338 db_create_link(
hDB, 0,
"/Logger/Runlog/SQL/Links BOR/Run number",
"/Runinfo/Run number");
2341 db_create_link(
hDB, 0,
"/Logger/Runlog/SQL/Links BOR/Comment",
"/Experiment/Run parameters/Comment");
2344 db_create_link(
hDB, 0,
"/Logger/Runlog/SQL/Links BOR/Start time",
"/Runinfo/Start time");
2353 db_create_link(
hDB, 0,
"/Logger/Runlog/SQL/Links EOR/Stop time",
"/Runinfo/Stop time");
2357 "/Equipment/Trigger/Statistics/Events sent");
2367 char hostname[80], username[80], password[80],
database[80], table[80], query[5000],
where[500];
2374 size =
sizeof(
BOOL);
2405 cm_msg(
MERROR,
"write_runlog_sql",
"Cannot find \"/Logger/Runlog/SQL/Links BOR");
2411 cm_msg(
MERROR,
"write_runlog_sql",
"Cannot find \"/Logger/Runlog/SQL/Links EOR");
2424 size =
sizeof(hostname);
2425 strcpy(hostname,
"localhost");
2428 size =
sizeof(username);
2429 strcpy(username,
"root");
2432 size =
sizeof(password);
2442 size =
sizeof(table);
2443 strcpy(table,
"Runlog");
2494 std::string filename;
2502 filename =
"runlog.log";
2511 db_create_link(
hDB, 0,
"/Logger/Runlog/ASCII/Links BOR/Run number",
"/Runinfo/Run number");
2514 db_create_link(
hDB, 0,
"/Logger/Runlog/ASCII/Links BOR/Comment",
"/Experiment/Run parameters/Comment");
2517 db_create_link(
hDB, 0,
"/Logger/Runlog/ASCII/Links BOR/Start time",
"/Runinfo/Start time");
2526 db_create_link(
hDB, 0,
"/Logger/Runlog/ASCII/Links EOR/Stop time",
"/Runinfo/Stop time");
2530 "/Equipment/Trigger/Statistics/Events sent");
2539 char filename[256], dir[256], path[256];
2544 size =
sizeof(
BOOL);
2554 cm_msg(
MERROR,
"write_runlog_ascii",
"Cannot find \"/Logger/Runlog/ASCII/Links BOR");
2560 cm_msg(
MERROR,
"write_runlog_ascii",
"Cannot find \"/Logger/Runlog/ASCII/Links EOR");
2569 size =
sizeof(filename);
2570 strcpy(filename,
"runlog.log");
2583 strcpy(path, filename);
2592 f =
fopen(path,
"wt");
2596 for (
int i = 0;;
i++) {
2605 for (
int i = 0;;
i++) {
2618 f =
fopen(path,
"at");
2625 for (
int i = 0;;
i++) {
2667 db_create_link(
hDB, 0,
"/Logger/Runlog/JSON/Links BOR/Run number",
"/Runinfo/Run number");
2670 db_create_link(
hDB, 0,
"/Logger/Runlog/JSON/Links BOR/Comment",
"/Experiment/Run parameters/Comment");
2673 db_create_link(
hDB, 0,
"/Logger/Runlog/JSON/Links BOR/Start time",
"/Runinfo/Start time");
2682 db_create_link(
hDB, 0,
"/Logger/Runlog/JSON/Links EOR/Stop time",
"/Runinfo/Stop time");
2686 "/Equipment/Trigger/Statistics/Events sent");
2701 size =
sizeof(
BOOL);
2711 cm_msg(
MERROR,
"write_runlog_json",
"Cannot find \"/Logger/Runlog/JSON/Links BOR");
2717 cm_msg(
MERROR,
"write_runlog_json",
"Cannot find \"/Logger/Runlog/JSON/Links EOR");
2760 mstrlcat(path, filename,
sizeof(path));
2772 cm_msg(
MERROR,
"write_runlog_json",
"Cannot open file \"%s\"", path);
2781 int buffer_size = 100000;
2782 char *buffer = (
char *)
malloc(buffer_size);
2834 char user[32],
pass[32];
2904 return (*con)->err_no;
2925 printf(
"WriterFtp: destructor\n");
2939 printf(
"WriterFtp: open path [%s]\n",
log_chn->path.c_str());
2957 printf(
"WriterFtp: write path [%s], size %d\n",
log_chn->path.c_str(), size);
2984 printf(
"WriterFtp: close path [%s]\n",
log_chn->path.c_str());
3039 "pipe was broken for redirection of data stream, please check the command usage:\"%s\"\nYou can try to run mlogger in console in interactive mode(just \"mlogger\") to obtaine more detail error message",
3040 log_chn->pipe_command.c_str());
3057 info->write_pointer =
info->buffer;
3136 info->write_pointer =
info->buffer;
3149 log_chn->statistics.disk_level = -1;
3177 cm_msg(
MERROR,
"midas_log_open",
"Compression level %d enabled, but output file name \'%s\' does not end with '.gz'",
log_chn->compression,
log_chn->path.c_str());
3185 "Output file name ends with '.gz', but compression level is zero");
3192 if (
log_chn->pipe_command[0] != 0){
3194 cm_msg(
MERROR,
"midas_log_open",
"Error: Pipe command not supported under Widnows");
3200 cm_msg(
MERROR,
"midas_log_open",
"Error: popen() failed, cannot open pipe stream");
3224 if (
log_chn->compression > 0) {
3227 cm_msg(
MERROR,
"midas_log_open",
"Error: gzdopen() failed, cannot open compression stream");
3240 if (
log_chn->settings.odb_dump)
3256 if (
log_chn->settings.odb_dump)
3295 free(
log_chn->midas_info->buffer);
3319#define EVENT_DEF_CACHE_SIZE 30
3337 cm_msg(
MERROR,
"db_get_event_definition",
"too many event definitions");
3351 cm_msg(
MERROR,
"db_get_event_definition",
"cannot find /equipment entry in ODB");
3359 cm_msg(
MERROR,
"db_get_event_definition",
"Cannot find event id %d under /equipment",
event_id);
3381 cm_msg(
MERROR,
"db_get_event_definition",
"unknown data format name \"%s\"",
str);
3396#define MAX_BANKS 100
3427 cm_msg(
MERROR,
"root_book_trees",
"cannot find \"/Equipment\" entry in ODB");
3466 "ROOT output only for MIDAS events, but %s in %s format",
eqkey.name,
str);
3630 cm_msg(
MERROR,
"root_write",
"Definition for event #%d not found under /Equipment", pevent->
event_id);
3643 for (
i = 0;
i <
ts->n_tree;
i++)
3644 if (
ts->event_tree[
i].event_id == pevent->
event_id)
3647 if (
i ==
ts->n_tree) {
3652 et =
ts->event_tree +
i;
3655 for (
i = 0;
i <
et->n_branch;
i++)
3690 for (
i = 0;
i <
et->n_branch;
i++)
3694 if (
i ==
et->n_branch)
3706 leaf->SetAddress(&
et->branch_len[
i]);
3718 for (
i = 0;
i <
et->n_branch;
i++)
3719 if (!
et->branch_filled[
i])
3726 return (
INT)
ts->f->GetBytesWritten();
3739 cm_msg(
MERROR,
"root_log_open",
"ROOT files can only reside on disk");
3757 size =
sizeof(
name);
3772 size =
sizeof(
level);
3774 f->SetCompressionLevel(
level);
3789 if (
log_chn->settings.odb_dump) {
3793 event.data_size = 0;
3815 free(
ts->event_tree);
3837 printf(
"WriterROOT: destructor\n");
3846 printf(
"WriterROOT: open path [%s]\n",
log_chn->path.c_str());
3860 printf(
"WriterROOT: write path [%s], size %d\n",
log_chn->path.c_str(), size);
3881 printf(
"WriterROOT: close path [%s]\n",
log_chn->path.c_str());
3911 if (
log_chn->settings.bzip2_compression) {
3923 if (
log_chn->settings.pbzip2_num_cpu) {
3928 if (
log_chn->settings.pbzip2_compression) {
3941#define CHECKSUM_NONE 0
3942#define CHECKSUM_ZLIB 1
3943#define CHECKSUM_CRC32C 2
3944#define CHECKSUM_SHA256 3
3945#define CHECKSUM_SHA512 4
3960 cm_msg(
MERROR,
"log_create_writer",
"channel %s unknown checksum code %d",
log_chn->path.c_str(), code);
3965#define COMPRESS_NONE 0
3966#define COMPRESS_ZLIB 1
3967#define COMPRESS_LZ4 2
3968#define COMPRESS_BZIP2 3
3969#define COMPRESS_PBZIP2 4
3978 cm_msg(
MERROR,
"log_create_writer",
"channel %s unknown compression code %d",
log_chn->path.c_str(), code);
3983#define OUTPUT_NONE 0
3984#define OUTPUT_NULL 1
3985#define OUTPUT_FILE 2
3987#define OUTPUT_ROOT 4
3988#define OUTPUT_PIPE 5
3994 int size =
sizeof(
value);
4003 std::string s =
set +
" (one of:" +
def +
")";
4006 const char*
value = s.c_str();
4012 (*def) += std::string(
" ") +
str;
4015 if (
val.find(
str) == 0) {
4078 if (
log_chn->output_module > 0) {
4083 cm_msg(
MERROR,
"log_create_writer",
"channel %s requested GZIP/ZLIB compression, output module must be FILE",
log_chn->path.c_str());
4093 cm_msg(
MERROR,
"log_create_writer",
"channel %s requested BZIP2 compression, output module must be FILE",
log_chn->path.c_str());
4104 cm_msg(
MERROR,
"log_create_writer",
"channel %s requested PBZIP2 compression, output module must be FILE",
log_chn->path.c_str());
4125 log_chn->statistics.disk_level = -1;
4133 cm_msg(
MERROR,
"log_create_writer",
"channel \"%s\" requested ROOT output, but mlogger is built without HAVE_ROOT",
log_chn->name.c_str());
4142 log_chn->statistics.disk_level = -1;
4148 if (
log_chn->pre_checksum_module) {
4157 cm_msg(
MERROR,
"log_create_writer",
"channel %s invalid output module value %d",
log_chn->path.c_str(),
log_chn->output_module);
4185 log_chn->statistics.disk_level = -1;
4189 log_chn->statistics.disk_level = -1;
4244 if (
log_chn->settings.odb_dump)
4248 double incr =
wr->fBytesOut -
log_chn->statistics.bytes_written_subrun;
4255 log_chn->statistics.bytes_written_subrun =
wr->fBytesOut;
4283 if (
log_chn->settings.odb_dump)
4292 double incr =
wr->fBytesOut -
log_chn->statistics.bytes_written_subrun;
4299 log_chn->statistics.bytes_written_subrun =
wr->fBytesOut;
4324 log_chn->statistics.files_written += 1;
4341 size_t pos =
str.rfind(
'/');
4342 if (pos != std::string::npos) {
4348 double MiB = 1024*1024;
4383 if (!
chn->do_disk_level)
4396 size =
sizeof(
BOOL);
4401 cm_msg(
MINFO,
"get_trans_flag",
"ODB \"/Logger/Async transitions\" is obsolete, please delete it");
4404 size =
sizeof(
BOOL);
4409 cm_msg(
MINFO,
"get_trans_flag",
"ODB \"/Logger/Multithread transitions\" is obsolete, please delete it");
4412 size =
sizeof(
BOOL);
4438 size =
sizeof(
BOOL);
4455 cm_msg(
MERROR,
"stop_the_run",
"another transition is in progress, will try again later");
4459 cm_msg(
MERROR,
"stop_the_run",
"cannot stop the run, cm_transition() status %d, error: %s",
status, errstr);
4475 size =
sizeof(
BOOL);
4480 cm_msg(
MINFO,
"start_the_run",
"Run auto restart canceled");
4485 size =
sizeof(
state);
4488 cm_msg(
MERROR,
"start_the_run",
"cannot get Runinfo/State in database, db_get_value() status %d",
status);
4495 cm_msg(
MINFO,
"start_the_run",
"Runinfo/State %d is not STATE_STOPPED, will try again in %d seconds",
state,
backoff);
4519 cm_msg(
MTALK,
"start_the_run",
"starting new run");
4522 cm_msg(
MERROR,
"start_the_run",
"cannot restart run: cm_transition() status %d, error: %s",
status, errstr);
4544 log_chn->statistics.events_written++;
4548 double incr =
wr->fBytesOut -
log_chn->statistics.bytes_written_subrun;
4555 log_chn->statistics.bytes_written_subrun =
wr->fBytesOut;
4572 log_chn->statistics.events_written++;
4591 cm_msg(
MTALK,
"log_write",
"Error writing output file, stopping run");
4600 log_chn->settings.event_limit > 0 &&
4601 log_chn->statistics.events_written >=
log_chn->settings.event_limit) {
4604 cm_msg(
MTALK,
"log_write",
"stopping run after having received %1.0lf events",
4605 log_chn->settings.event_limit);
4627 log_chn->statistics.bytes_written_subrun = 0;
4637 log_chn->statistics.bytes_written_subrun >=
log_chn->settings.subrun_byte_limit) {
4649 log_chn->statistics.bytes_written_subrun = 0;
4673 log_chn->statistics.bytes_written_subrun = 0;
4686 log_chn->settings.byte_limit > 0 &&
4687 log_chn->statistics.bytes_written >=
log_chn->settings.byte_limit) {
4690 cm_msg(
MTALK,
"log_write",
"stopping run after having received %1.0lf mega bytes",
4691 log_chn->statistics.bytes_written / 1
E6);
4703 const double MiB = 1024*1024;
4719 cm_msg(
MTALK,
"log_write",
"disk nearly full, stopping the run");
4735static std::vector<MidasHistoryInterface*>
mh;
4749 printf(
"tag %d: name \"%s\", type %d, n_data %d\n",
i, tags[
i].
name, tags[
i].
type, tags[
i].n_data);
4757 cm_msg(
MERROR,
"add_event",
"Duplicate event name \'%s\' with event id %d", event_name,
event_id);
4780 cm_msg(
MERROR,
"add_event",
"Invalid tag %d \'%s\' in event %d \'%s\': cannot do history for TID_STRING data, sorry!",
i, tags[
i].
name,
event_id, event_name);
4784 cm_msg(
MERROR,
"add_event",
"Invalid tag %d \'%s\' in event %d \'%s\': cannot do history for TID_INT64 data, sorry!",
i, tags[
i].
name,
event_id, event_name);
4788 cm_msg(
MERROR,
"add_event",
"Invalid tag %d \'%s\' in event %d \'%s\': cannot do history for TID_UINT64 data, sorry!",
i, tags[
i].
name,
event_id, event_name);
4800 cm_msg(
MERROR,
"add_event",
"Invalid tag %d \'%s\' in event %d \'%s\': has trailing spaces",
i, tags[
i].
name,
event_id, event_name);
4805 for (
unsigned i=0;
i<
mh.size();
i++) {
4806 status =
mh[
i]->hs_define_event(event_name, timestamp,
ntags, tags);
4808 cm_msg(
MERROR,
"add_event",
"Cannot define event \"%s\", hs_define_event() status %d", event_name,
status);
4816 cm_msg(
MERROR,
"add_event",
"Cannot define event \"%s\", db_get_record_size() status %d", event_name,
status);
4830 cm_msg(
MERROR,
"add_event",
"Cannot allocate data buffer for event \"%s\" size %d", event_name, size);
4839 "Cannot hotlink event %d \"%s\" for history logging, db_open_record() status %d",
4848 printf(
"Created event %d for equipment \"%s\", %d tags, size %d\n",
event_id, event_name,
ntags, size);
4874 for (
unsigned i=0;
i<
mh.size();
i++)
4896 size =
sizeof(active);
4901 size =
sizeof(
debug);
4917 size =
sizeof(active);
4922 size =
sizeof(
debug);
4933 size =
sizeof(active);
4938 size =
sizeof(
debug);
4949 size =
sizeof(active);
4954 size =
sizeof(
debug);
4965 size =
sizeof(active);
4970 size =
sizeof(
debug);
4981 size =
sizeof(active);
4986 size =
sizeof(
debug);
4996 cm_msg(
MERROR,
"open_history",
"Something is wrong with /Logger/History, db_find_key() status %d",
status);
5039 cm_msg(
MINFO,
"open_history",
"Writing history to channel \'%s\' type \'%s\'",
hi->name,
hi->type);
5047 for (
unsigned i=0;
i<
mh.size();
i++) {
5058 cm_msg(
MERROR,
"open_history",
"mlogger ODB setting /History/PerVariableHistory is obsolete, please delete it. Use /Logger/History/MIDAS/PerVariableHistory instead");
5067 cm_msg(
MINFO,
"open_history",
"Per-variable history is enabled");
5083 "/Equipment/Trigger/Statistics/Events per sec.");
5087 "/Equipment/Trigger/Statistics/kBytes per sec.");
5096 cm_msg(
MINFO,
"open_history",
"Cannot find /Equipment entry in database, history system is inactive");
5101 cm_msg(
MERROR,
"open_history",
"Cannot find /Equipment entry in database, db_find_key() status %d",
status);
5115 size =
sizeof(min_period);
5119 if (min_period > 0) {
5127 cm_msg(
MERROR,
"open_history",
"Equipment name \'%s\' contains characters \':\', this may break the history system",
eq_name);
5131 cm_msg(
MERROR,
"open_history",
"Cannot find /Equipment/%s/Variables entry in database",
eq_name);
5135 size =
sizeof(
eq_id);
5145 (
"\n==================== Equipment \"%s\", ID %d =======================\n",
5149 for (n_var = 0,
n_tags = 0;; n_var++) {
5176 cm_msg(
MINFO,
"open_history",
"Equipment \"%s\" history is enabled, but there are no Variables in ODB",
eq_name);
5215 printf(
"Using \"/Equipment/%s/Settings/Names\" for variable \"%s\"\n",
eq_name,
varkey.name);
5225 "Array size mismatch: \"/Equipment/%s/Settings/%s\" has %d entries while \"/Equipment/%s/Variables/%s\" has %d entries",
5234 for (
j = 0;
j <
varkey.num_values;
j++) {
5240 size =
sizeof(
xname);
5269 printf(
"Defined tag %d, name \"%s\", type %d, num_values %d\n",
5357 for (
li = 0;;
li++) {
5368 cm_msg(
MERROR,
"open_history",
"Only subkeys allows in /history/Links");
5373 printf(
"\n==================== History link \"%s\", ID %d =======================\n",
5377 for (
i = n_var = 0;;
i++) {
5400 for (
i = 0, size = 0, n_var = 0;;
i++) {
5426 printf(
"Defined tag \"%s\", type %d, num_values %d\n",
5427 tag[n_var].
name, tag[n_var].
type, tag[n_var].n_data);
5429 size +=
varkey.total_size;
5456 strcpy(tag[0].
name,
"State");
5460 strcpy(tag[1].
name,
"Run number");
5464 const char* event_name =
"Run transitions";
5466 for (
unsigned i=0;
i<
mh.size();
i++) {
5467 status =
mh[
i]->hs_define_event(event_name,
now, 2, tag);
5469 cm_msg(
MERROR,
"add_event",
"Cannot define event \"%s\", hs_define_event() status %d", event_name,
status);
5507 printf(
"flush history buffers!\n");
5509 for (
unsigned h = 0; h <
mh.size(); h++)
5510 mh[h]->hs_flush_buffers();
5526 for (
int i = 0;;
i++) {
5545 for (
unsigned h=0; h<
mh.size(); h++) {
5546 mh[h]->hs_disconnect();
5580 printf(
"Error in history system, aborting.\n");
5592 for (
unsigned h=0; h<
mh.size(); h++) {
5623 for (
i = 0, total_size = 0;;
i++) {
5638 printf(
"Error in history system, aborting.\n");
5650 for (
unsigned h=0; h<
mh.size(); h++)
5700 log_chn->pipe_command += *s++;
5704 log_chn->pipe_command += *s++;
5767 path +=
log_chn->writer->wr_get_file_ext();
5797 if (
log_chn->pipe_command.back() !=
' ')
5800 log_chn->pipe_command += path;
5823 if (
chn->handle ||
chn->ftp_con||
chn->pfile) {
5827 if (
chn->buffer_handle) {
5839 }
while (n_bytes > 0);
5851 chn->stats_hkey = 0;
5852 chn->settings_hkey = 0;
5868 if (
chn->buffer_handle) {
5875 if (
chn->msg_request_id)
5898 for (
unsigned h=0; h<
mh.size(); h++)
5919 printf(
"Channel %s settings updated\n",
log_chn->name.c_str());
5953 std::string
str =
"last.json";
5971 size =
sizeof(
BOOL);
5989 strcpy(error,
"Cannot create channel entry in database");
5996 strcpy(error,
"Cannot create channel entry in database");
6026 strcpy(error,
"Cannot find channel settings info");
6034 strcpy(error,
"Cannot find channel statistics info");
6043 chn->statistics.events_written = 0;
6044 chn->statistics.bytes_written = 0;
6045 chn->statistics.bytes_written_uncompressed = 0;
6046 chn->statistics.bytes_written_subrun = 0;
6055 strcpy(error,
"Cannot read channel info");
6078 sprintf(error,
"Invalid channel type \"%s\", pease use \"Tape\", \"FTP\" or \"Disk\"",
chn_settings->type);
6086 chn->compression = 0;
6087 size =
sizeof(
chn->compression);
6092 chn->subrun_number = 0;
6103 sprintf(error,
"Cannot open file \'%s\' (See messages)",
chn->path.c_str());
6105 sprintf(error,
"File \'%s\' exists already, run start aborted",
chn->path.c_str());
6107 sprintf(error,
"No tape in device \'%s\'",
chn->path.c_str());
6109 sprintf(error,
"Tape error, cannot start run");
6111 sprintf(error,
"Device \'%s\' used by someone else",
chn->path.c_str());
6113 sprintf(error,
"Cannot open FTP channel to \'%s\'",
chn->path.c_str());
6115 sprintf(error,
"No ROOT support compiled into mlogger, please compile with -DHAVE_ROOT flag");
6118 sprintf(error,
"Invalid data format, please use \"MIDAS\", \"ASCII\", \"DUMP\" or \"ROOT\"");
6125 if (
chn->stats_hkey)
6127 if (
chn->settings_hkey)
6136 cm_msg(
MERROR,
"tr_start",
"Cannot change access mode for statistics record, error %d",
status);
6138 cm_msg(
MINFO,
"tr_start",
"Recovered access mode for statistics record of channel \"%s\"",
chn->name.c_str());
6143 cm_msg(
MERROR,
"tr_start",
"Cannot open statistics record for channel \"%s\", error %d",
chn->name.c_str(),
status);
6148 cm_msg(
MERROR,
"tr_start",
"db_watch() status %d, cannot open channel settings record, probably other logger is using it",
status);
6164 sprintf(error,
"Cannot place event request");
6182 sprintf(error,
"Cannot place event request");
6194 cm_msg(
MTALK,
"tr_start",
"tape mounting finished");
6200 sprintf(error,
"Error in history system, aborting run start");
6223 printf(
"tr_start: run %d started in %d ms: odb dump %d ms, close channels %d ms, configure channels %d ms, configure history %d ms, write runlog %d ms\n",
6253 cm_msg(
MINFO,
"tr_start_abort",
"Deleting previous file \"%s\"",
chn->path.c_str());
6302 size =
sizeof(
flag);
6306 strcpy(
str,
"run%d.json");
6311 strcpy(
str,
"run%d.json");
6317 strcpy(filename,
str);
6338 cm_msg(
MTALK,
"tr_stop",
"all tape channels closed");
6351 size =
sizeof(delay);
6360 printf(
"tr_stop: run %d stopped in %d ms: close channels %d ms, odb dump %d ms, write run log %d ms, write history %d ms\n",
6414 if (
chn->handle == 0 &&
chn->ftp_con ==
NULL)
6418 if (
chn->request_id == request_id) {
6424 if (
chn->msg_request_id == request_id) {
6483 else if (
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'D')
6485 else if (
argv[
i][0] ==
'-' &&
argv[
i][1] ==
's')
6487 else if (
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'v')
6489 else if (
argv[
i][0] ==
'-') {
6492 if (
argv[
i][1] ==
'e')
6496 printf(
"usage: mlogger [-e Experiment] [-d] [-D] [-s] [-v]\n\n");
6503 printf(
"Becoming a daemon...\n");
6514 printf(
"Logger runs already.\n");
6552 printf(
"Error in history system, aborting startup.\n");
6562 printf(
"Data directory is \"%s\" unless specified under /Logger/channels/\n",
data_dir.c_str());
6569 printf(
"Message directory is \"%s\" unless specified in /Logger/Message dir\n",
message_dir.c_str());
6578 printf(
"History directory is \"%s\" unless specified under /Logger/history/\n",
history_dir.c_str());
6599 printf(
"\nMIDAS logger started. Stop with \"!\"\n");
6645 cm_msg(
MTALK,
"main",
"another attempt to stop the run");
6660 if ((
char)
ch ==
'!')
6675 printf(
"Stopping image history threads...");
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
int wr_close(LOG_CHN *log_chn, int run_number)
std::string wr_get_file_ext()
int wr_open(LOG_CHN *log_chn, int run_number)
std::string wr_get_chain()
WriterCRC32C(LOG_CHN *log_chn, int level, WriterInterface *wr)
int wr_close(LOG_CHN *log_chn, int run_number)
std::string wr_get_file_ext()
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
WriterCRC32Zlib(LOG_CHN *log_chn, int level, WriterInterface *wr)
std::string wr_get_chain()
int wr_open(LOG_CHN *log_chn, int run_number)
int wr_close(LOG_CHN *log_chn, int run_number)
WriterFile(LOG_CHN *log_chn)
std::string wr_get_chain()
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
int wr_open(LOG_CHN *log_chn, int run_number)
std::string wr_get_file_ext()
WriterFtp(LOG_CHN *log_chn)
int wr_open(LOG_CHN *log_chn, int run_number)
std::string wr_get_chain()
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
int wr_close(LOG_CHN *log_chn, int run_number)
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
std::string wr_get_chain()
WriterGzip(LOG_CHN *log_chn, int compress)
std::string wr_get_file_ext()
int wr_close(LOG_CHN *log_chn, int run_number)
int wr_open(LOG_CHN *log_chn, int run_number)
virtual ~WriterInterface()
virtual int wr_close(LOG_CHN *log_chn, int run_number)=0
virtual int wr_open(LOG_CHN *log_chn, int run_number)=0
virtual std::string wr_get_chain()=0
virtual std::string wr_get_file_ext()
virtual int wr_write(LOG_CHN *log_chn, const void *data, const int size)=0
std::string wr_get_file_ext()
MLZ4F_compressionContext_t fContext
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
int wr_open(LOG_CHN *log_chn, int run_number)
MLZ4F_preferences_t fPrefs
WriterLZ4(LOG_CHN *log_chn, WriterInterface *wr)
std::string wr_get_chain()
int wr_close(LOG_CHN *log_chn, int run_number)
int wr_open(LOG_CHN *log_chn, int run_number)
std::string wr_get_file_ext()
bool fSimulateCompression
WriterNull(LOG_CHN *log_chn)
std::string wr_get_chain()
int wr_close(LOG_CHN *log_chn, int run_number)
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
std::string wr_get_file_ext()
int wr_open(LOG_CHN *log_chn, int run_number)
int wr_close(LOG_CHN *log_chn, int run_number)
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
WriterPopen(LOG_CHN *log_chn, const char *pipe_command, const char *file_ext)
std::string wr_get_chain()
std::string toHex(unsigned char c)
std::string wr_get_chain()
int wr_close(LOG_CHN *log_chn, int run_number)
int wr_open(LOG_CHN *log_chn, int run_number)
WriterSHA256(LOG_CHN *log_chn, int level, WriterInterface *wr)
std::string toString(const unsigned char sha256sum[32])
mbedtls_sha256_context fCtx
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
std::string wr_get_file_ext()
int wr_write(LOG_CHN *log_chn, const void *data, const int size)
std::string toString(const unsigned char sha512sum[64])
mbedtls_sha512_context fCtx
std::string toHex(unsigned char c)
std::string wr_get_file_ext()
std::string wr_get_chain()
int wr_close(LOG_CHN *log_chn, int run_number)
WriterSHA512(LOG_CHN *log_chn, int level, WriterInterface *wr)
int wr_open(LOG_CHN *log_chn, int run_number)
INT transition(INT run_number, char *error)
uint32_t crc32c(uint32_t crc, const void *buf, size_t len)
int ftp_login(FTP_CON **con, const char *host, unsigned short port, const char *user, const char *password, const char *account)
int ftp_close(FTP_CON *con)
int ftp_command(FTP_CON *con, const char *command, const char *param,...)
#define FTP_RESPONSE_ERROR
void ftp_debug(int(*debug_func)(const char *message), int(*error_func)(const char *message))
int ftp_send(int sock, const char *buffer, int n_bytes_to_write)
int ftp_bye(FTP_CON *con)
#define ftp_chdir(ftp, dir)
#define ftp_open_write(ftp, file)
INT bk_iterate32a(const void *event, BANK32A **pbk32a, void *pdata)
INT bk_swap(void *event, BOOL force)
BOOL bk_is32a(const void *event)
BOOL bk_is32(const void *event)
INT bk_iterate32(const void *event, BANK32 **pbk, void *pdata)
INT bk_iterate(const void *event, BANK **pbk, void *pdata)
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
INT bm_delete_request(INT request_id)
INT bm_request_event(HNDLE buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, HNDLE *request_id, EVENT_HANDLER *func)
INT bm_set_cache_size(INT buffer_handle, size_t read_size, size_t write_size)
INT bm_close_buffer(INT buffer_handle)
INT bm_compose_event(EVENT_HEADER *event_header, short int event_id, short int trigger_mask, DWORD data_size, DWORD serial)
INT cm_register_transition(INT transition, INT(*func)(INT, char *), INT sequence_number)
INT cm_yield(INT millisec)
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
INT cm_transition(INT transition, INT run_number, char *errstr, INT errstr_size, INT async_flag, INT debug_flag)
INT cm_disconnect_experiment(void)
std::string cm_get_path()
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
INT cm_set_watchdog_params(BOOL call_watchdog, DWORD timeout)
INT cm_exist(const char *name, BOOL bUnique)
static void xwrite(const char *filename, int fd, const void *data, int size)
#define CM_TRANSITION_IN_PROGRESS
#define DB_NO_MORE_SUBKEYS
#define SS_INVALID_FORMAT
static INT hs_write_event(DWORD event_id, const void *data, DWORD size)
#define MESSAGE_BUFFER_NAME
#define MAX_STRING_LENGTH
#define MESSAGE_BUFFER_SIZE
double ss_disk_size(const char *path)
time_t ss_mktime(struct tm *tms)
INT ss_getchar(BOOL reset)
double ss_disk_free(const char *path)
double ss_file_size(const char *path)
INT ss_daemon_init(BOOL keep_stdout)
INT cm_msg_flush_buffer()
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
BOOL equal_ustring(const char *str1, const char *str2)
INT db_get_data_index(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT idx, DWORD type)
INT db_send_changed_records()
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT db_save_json(HNDLE hDB, HNDLE hKey, const char *filename, int flags)
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
INT db_lock_database(HNDLE hDB)
std::string strcomb1(const char **list)
INT db_save_xml(HNDLE hDB, HNDLE hKey, const char *filename)
INT db_get_path(HNDLE hDB, HNDLE hKey, char *path, INT buf_size)
INT db_get_record1(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align, const char *rec_str)
INT db_copy(HNDLE hDB, HNDLE hKey, char *buffer, INT *buffer_size, const char *path)
INT db_get_record_size(HNDLE hDB, HNDLE hKey, INT align, INT *buf_size)
INT db_get_data(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
INT db_create_key(HNDLE hDB, HNDLE hKey, const char *key_name, DWORD type)
INT db_check_record(HNDLE hDB, HNDLE hKey, const char *keyname, const char *rec_str, BOOL correct)
INT db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
INT db_copy_xml(HNDLE hDB, HNDLE hKey, char *buffer, int *buffer_size, bool header)
INT db_unlock_database(HNDLE hDB)
INT db_unwatch(HNDLE hDB, HNDLE hKey)
INT db_set_mode(HNDLE hDB, HNDLE hKey, WORD mode, BOOL recurse)
INT db_save(HNDLE hDB, HNDLE hKey, const char *filename, BOOL bRemote)
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
INT db_get_link(HNDLE hDB, HNDLE hKey, KEY *key)
INT EXPRT db_get_value_string(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int index, std::string *s, BOOL create, int create_string_length)
INT db_watch(HNDLE hDB, HNDLE hKey, void(*dispatcher)(INT, INT, INT, void *), void *info)
INT db_enum_link(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
int EXPRT json_write_anything(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end, int level, int must_be_subdir, int flags, time_t timestamp)
INT db_sprintf(char *string, const void *data, INT data_size, INT idx, DWORD type)
INT db_set_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
BOOL ends_with_ustring(const char *str, const char *suffix)
void json_write(char **buffer, int *buffer_size, int *buffer_end, int level, const char *s, int quoted)
INT db_open_record1(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info, const char *rec_str)
INT db_set_record(HNDLE hDB, HNDLE hKey, void *data, INT buf_size, INT align)
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
INT db_close_record(HNDLE hDB, HNDLE hKey)
INT db_create_record(HNDLE hDB, HNDLE hKey, const char *orig_key_name, const char *init_str)
INT db_create_link(HNDLE hDB, HNDLE hKey, const char *link_name, const char *destination)
INT db_protect_database(HNDLE hDB)
const char * rpc_tid_name(INT id)
int hs_save_event_list(const std::vector< std::string > *pevents)
int hs_get_history(HNDLE hDB, HNDLE hKey, int flags, int debug_flag, MidasHistoryInterface **mh)
std::string history_dir()
char exp_name[NAME_LENGTH]
BOOL debug
debug printouts
INT bor(INT run_number, char *error)
char host_name[HOST_NAME_LENGTH]
static void compress(int init_bits, gdGifBuffer *buffer, gdImagePtr im)
static void output(code_int code)
bool ends_with_char(const std::string &s, char c)
INT bm_get_buffer_level(INT buffer_handle, INT *n_bytes)
std::string msprintf(const char *format,...)
#define DIR_SEPARATOR_STR
#define JSFLAG_FOLLOW_LINKS
#define JSFLAG_OMIT_LAST_WRITTEN
#define DEFAULT_BUFFER_SIZE
#define JSFLAG_OMIT_NAMES
#define message(type, str)
#define write(n, a, f, d)
int select_compression_module(HNDLE hDB, HNDLE hSet, const char *name)
void log_history(HNDLE hDB, HNDLE hKey, void *info)
void receive_event(HNDLE hBuf, HNDLE request_id, EVENT_HEADER *pheader, void *pevent)
void create_runlog_json_tree()
INT tr_stop(INT run_number, char *error)
#define DISK_CHECK_INTERVAL_MILLISEC
std::string get_value(HNDLE hDB, HNDLE hDir, const char *name)
INT tr_start_abort(INT run_number, char *error)
static std::vector< MidasHistoryInterface * > mh
EVENT_DEF * db_get_event_definition(short int event_id)
void log_odb_dump_json(LOG_CHN *log_chn, short int event_id, INT run_number)
void maybe_flush_history(time_t now)
void log_odb_dump(LOG_CHN *log_chn, short int event_id, INT run_number)
int log_create_writer(LOG_CHN *log_chn)
void stop_image_history()
#define CHN_TREE_STR(_name)
INT tr_pause(INT run_number, char *error)
static std::vector< std::string > history_events
int log_generate_file_name(LOG_CHN *log_chn)
static FILE * fopen_wx(const char *filename)
static int get_trans_flag()
void log_system_history(HNDLE hDB, HNDLE hKey, void *info)
int select_checksum_module(HNDLE hDB, HNDLE hSet, const char *name)
INT tr_start(INT run_number, char *error)
WriterInterface * NewCompression(LOG_CHN *log_chn, int code, WriterInterface *chained)
INT log_open(LOG_CHN *log_chn, INT run_number)
#define EVENT_DEF_CACHE_SIZE
INT ftp_error(const char *message)
time_t last_history_flush
INT tr_resume(INT run_number, char *error)
WriterInterface * NewChecksum(LOG_CHN *log_chn, int code, int level, WriterInterface *chained)
WriterInterface * NewWriterBzip2(LOG_CHN *log_chn)
int maybe_check_disk_level()
INT log_close(LOG_CHN *log_chn, INT run_number)
void create_runlog_ascii_tree()
void odb_save(const char *filename, bool make_file_readonly)
void log_odb_dump_xml(LOG_CHN *log_chn, short int event_id, INT run_number)
void set_value(HNDLE hDB, HNDLE hDir, const char *name, const std::string &set, const std::string &def)
int check_add(int v, int n, const std::string &val, const char *str, bool bdef, std::string *def, std::string *sel)
static std::string TimeToString(time_t t)
#define CHN_SETTINGS_STR(_name)
INT ftp_open(const char *xdestination, FTP_CON **con)
std::vector< LOG_CHN * > log_channels
int select_output_module(HNDLE hDB, HNDLE hSet, const char *name)
static void watch_settings(HNDLE hDB, HNDLE hKey, HNDLE index, void *info)
static std::string IntToString(int value)
int get_number_image_history_threads()
LOG_CHN * new_LOG_CHN(const char *name)
static int write_history(DWORD transition, DWORD run_number)
static int add_event(int *indexp, time_t timestamp, int event_id, const char *event_name, HNDLE hKey, int ntags, const TAG *tags, time_t min_period, int hotlink)
INT log_write(LOG_CHN *log_chn, EVENT_HEADER *pheader)
static bool check_file_exists(const char *filename)
static struct hist_log_s * hist_log
void log_odb_dump_odb(LOG_CHN *log_chn, short int event_id, INT run_number)
#define CHN_STATISTICS_STR(_name)
void start_image_history()
static std::string xpathname(const char *xpath, int level)
void write_runlog_json(BOOL bor)
void write_runlog_ascii(BOOL bor)
int log_disk_level(LOG_CHN *log_chn, double *pdisk_size, double *pdisk_free)
int close_channels(int run_number, BOOL *p_tape_flag)
WriterInterface * NewWriterPbzip2(LOG_CHN *log_chn)
int stop_the_run(int restart)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32])
SHA-256 final digest.
void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 process buffer.
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
Clear SHA-256 context.
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
Initialize SHA-256 context.
void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
SHA-256 context setup.
void mbedtls_sha512_starts(mbedtls_sha512_context *ctx, int is384)
SHA-512 context setup.
void mbedtls_sha512_update(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 process buffer.
void mbedtls_sha512_free(mbedtls_sha512_context *ctx)
Clear SHA-512 context.
void mbedtls_sha512_finish(mbedtls_sha512_context *ctx, unsigned char output[64])
SHA-512 final digest.
void mbedtls_sha512_init(mbedtls_sha512_context *ctx)
Initialize SHA-512 context.
uint32_t bzip2_compression
double obsolete_tape_capacity
uint32_t pbzip2_compression
uint32_t gzip_compression
double bytes_written_subrun
double bytes_written_total
double bytes_written_uncompressed
CHN_STATISTICS statistics
SHA-256 context structure.
SHA-512 context structure.