27 const std::string save =
"save";
28 const std::string
stop =
"stop";
31 const int MINIMUM_NUMBER_OF_MESSAGES = 100;
32 const double MINIMUM_ELAPSED_TIME_S = 60*60;
42 static const int MAXIMUM_FILE_NUMBER = 100;
49 JLoggerFile(
const std::string&
path) :
74 for (
int i = 0; !this->is_open() && i != MAXIMUM_FILE_NUMBER; ++i) {
80 <<
"_" << this->getYear() <<
'-' <<
FILL(2,
'0') << this->getMonth() <<
'-' <<
FILL(2,
'0') << this->getDay();
111 std::string file_name;
126 int main(
int argc,
const char *argv[])
142 JParser<> zap(
"Auxiliary program to save logger messages from ControlHost server.");
144 zap[
'H'] =
make_field(hostname) =
"localhost";
153 catch(
const exception &error) {
154 FATAL(error.what() << endl);
157 if (happy_hour.empty()) {
159 WARNING(
"No happy hours (option -W); set to midnight." << endl);
161 happy_hour.insert(0);
183 JLoggerFile out(
path);
187 DEBUG(
"Open file " << out.getFilename() << endl);
194 for (
int number_of_messages; buffer.size() !=
stop.size() || string(buffer.data(),
stop.size()) !=
stop; ) {
196 const int check = in.
CheckHead(prefix, timeout);
198 DEBUG(
"Check head " << check << endl);
202 FATAL(
"Error at JControlHost::CheckHead " << check << endl);
204 }
else if (check == 1) {
208 DEBUG(
"Message <" << buffer <<
">" << endl);
210 if (buffer ==
stop) {
214 }
else if (buffer == save) {
216 DEBUG(
"Close file " << out.getFilename() << endl);
221 DEBUG(
"Open file " << out.getFilename() << endl);
225 ++number_of_messages;
227 if ( ! (out << buffer << endl)) {
228 FATAL(
"Error writing to file " << out.getFilename() << endl);
233 if (check == 0 || number_of_messages > MINIMUM_NUMBER_OF_MESSAGES) {
235 number_of_messages = 0;
243 DEBUG(
"Close file " << out.getFilename() << endl);
248 DEBUG(
"Open file " << out.getFilename() << endl);
256 ERROR(error << endl);
Utility class to parse command line options.
int main(int argc, char *argv[])
void set() const
Set to actual time.
static const std::string MESSAGE_TAG
Message logging tag.
int Subscribe(const JSubscription &subscription)
Subscribe to single tag.
int SendMeAlways()
Tell server to send messages forever.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
std::string getFullPath(const std::string &path)
Get full path, i.e. add JEEP::PATHNAME_SEPARATOR if necessary.
T * open(const std::string &file_name)
Open file.
then usage $script[port]< option > nPossible stop
Auxiliary class for time values.
int CheckHead(JPrefix &prefix, JTimeval timeout=JTimeval::min())
Check for header, without waiting.
void open(const char *name, int open_mode=std::ios::out)
$WORKDIR driver txt done cat $WORKDIR driver txt<< EOFprocess ${DATAFILTER}$FILTER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataFilter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAFILTER}-P $PORT</dev/null > &/dev/null)&';process ${DATAWRITER}$WRITER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataWriter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAWRITER}</dev/null > &/dev/null)&';print enterevent ev_init{RC_CMD}event ev_reset{RC_CMD}event ev_init{RC_CMD}event ev_configure{RC_DFLTR%<$WORKDIR/ev_configure_datafilter.txt > RC_DOM<$WORKDIR/ev_configure_domsimulator.txt > RC_DWRT path
int GetFullString(std::string &buffer)
Receive string.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void close(std::istream *pf)
Close file.
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
Exception for ControlHost.
Auxiliary class for all subscription.
General purpose messaging.
Auxiliary data structure for sequence of same character.
double getElapsedTime(const JDateAndTime &object) const
Get elapsed time since given date and time.
static JStat getFileStatus
Function object for file status.
General purpose message reporting.
Auxililary class to get date and time.
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
int getHour() const
hours after midnight [0-23]
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
static void Throw(const bool option)
Enable/disable throw option.