mirror of
https://github.com/nasa/fprime.git
synced 2025-12-15 14:05:24 -06:00
* Revise command response port Replace inline enum with XML enum type Generate XML from FPP Revise uses to match * Revise xml-gen script * Revise event ports Replace inline enums with external enums * Add missing files * Revise ActiveLogger * Revise text log port * Revise text log port Replace inline enum with external LogSeverity enum Now Log and TextLog share the same enum for severity * Revise Fw/Prm * Revise uses of Fw/Prm * Revise Fw/Cmd model * Revise Fw/Cmd build * Revise build for Fw/Cmd * Refactor Fw/Log model * Refactor build for Fw/Prm * Revise build scripts Remove workarounds after compiler fix * Revise model Revise build scripts Regerate XML * Revise FPP model in Fw * Add gen-xml * Add metadata files * Add redo scripts * Remove gen-xml scripts * Revise redo scripts * Revise redo scripts * Add redo scripts * Add FPP model for Fw/Com * Add FPP model for Fw/Time * Revise redo scripts * Add FPP model for Fw/Tlm * Revise redo scripts * Revise redo scripts * Revise redo scripts, gitignore * Remove unused file * Revise redo scripts * Add FPP.adoc * Add FPP model for Svc/Cycle * Revise defs.fpp and build rules * Revise do files Rename fpp-defs to defs * Update redo scripts * Revise redo scripts * Fix build rules * Add FPP model for Svc/Sched * Revise update script * Rename defs.fpp --> locs.fpp * Revise build scripts * Revise Svc.Cycle model Make TimerVal argument by value, not by reference This is required for compliance with FPP semantics, because Svc.Cycle is used in async input ports * Revert "Revise Svc.Cycle model" This reverts commit a31c12f1c0a9639da818d79da4f7ddd036c0b3d8. Under the revised semantics of FPP, this change is not necessary. * Revise Fw/Types build Add missing file * Revise FatalHandler Abort with SIGABRT, not SIGSEGV * Add FPP model for Ping port * Revise GDS launcher Make the HTML server port configurable Interpret -g 5001 as "Run the HTML GUI at port 5001" * Fix bug in XML array parser * Revise build scripts * Revise build script * Fix merge errors * Fix merge errors * Fix redo scripts * redo not overwriting Svc/FileDownlink .xml files * Remove redo database * Revise .gitignore * Revise FileDownlink FPP model * pre redo all in Drv/ByteStreamDriveModel * Revisited SignalPair to run redo all * redo all in Ref/SignalGen * Saving before running redo all * /Svc/Watchdog pre redo all * All Svc Enums etc. done minus /Svc/PolyIf and /Svc/WatchDog * Forgot to add /Seq/Seq.fpp on last commit * Created Type.fpp, ran redo xml in /Svc/Seq * /Svc/PolyIf pre redo all * /Svc/PolyIf returning .hpp error on fprime-util build * Svc ports etc. complete * Svc/ActiveLogger pre redo * /Svc/PolyDb pre redo * /Svc/ActiveTextLogger pre-redo * /Svc/ActiveTextLogger post redo * Svc/ComSplitter pre redo * Svc/ComSplitter post redo * /Svc/Deframer pre redo * Svc/Deframer post redo * /Svc/FatalHandler pre redo * /Svc/FatalHandler post redo * /Svc/Framer pre redo * /Svc/FramerComponentAi post redo * /Svc/LinuxTimer pre redo * post redo for /Svc/LinuxTimer /Svc/PolyDb * /Svc/Time pre redo * /Svc/Time post redo * /Svc/TlmChan pre redo * /Svc/TlmChan post redo * Remove files deleted from mainline * Revert change to Fatal Handler * Rename CommandResponse to CmdResponse * Revert name of enum constant * updated Fw/types.fpp * Added ActiveRateGroupOutputPorts to Fpconfig.fpp, Svc/ActiveRateGroup pre redo * /Svc/ActiveRateGroup component finished * Revise build scripts * Revise Ref redo build Make it into a separate project * Revise fpp build * Revise fpp build * Revise ActiveRateGroup Put AcConstants variable back in for now * Revise FPP model * Revise fpp model Add AcConstants.fpp * Remove local setup scripts * Fix spelling in comment * Revise spell check Co-authored-by: jweadick <joshua.m.weadick@jpl.nasa.gov>
153 lines
5.6 KiB
C++
153 lines
5.6 KiB
C++
// \copyright
|
|
// Copyright 2009-2015, by the California Institute of Technology.
|
|
// ALL RIGHTS RESERVED. United States Government Sponsorship
|
|
// acknowledged.
|
|
|
|
#include <Svc/ActiveTextLogger/ActiveTextLoggerImpl.hpp>
|
|
#include <Fw/Types/Assert.hpp>
|
|
#include <time.h>
|
|
|
|
namespace Svc {
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Initialization/Exiting
|
|
// ----------------------------------------------------------------------
|
|
|
|
ActiveTextLoggerComponentImpl::ActiveTextLoggerComponentImpl(const char* name) :
|
|
ActiveTextLoggerComponentBase(name),
|
|
m_log_file()
|
|
{
|
|
|
|
}
|
|
|
|
ActiveTextLoggerComponentImpl::~ActiveTextLoggerComponentImpl()
|
|
{
|
|
|
|
}
|
|
|
|
void ActiveTextLoggerComponentImpl::init(NATIVE_INT_TYPE queueDepth, NATIVE_INT_TYPE instance)
|
|
{
|
|
ActiveTextLoggerComponentBase::init(queueDepth,instance);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Handlers to implement for typed input ports
|
|
// ----------------------------------------------------------------------
|
|
|
|
void ActiveTextLoggerComponentImpl::TextLogger_handler(NATIVE_INT_TYPE portNum,
|
|
FwEventIdType id,
|
|
Fw::Time &timeTag,
|
|
Fw::LogSeverity severity,
|
|
Fw::TextLogString &text)
|
|
{
|
|
|
|
// Currently not doing any input filtering
|
|
// TKC - 5/3/2018 - remove diagnostic
|
|
if (Fw::LogSeverity::DIAGNOSTIC == severity.e) {
|
|
return;
|
|
}
|
|
|
|
// Format the string here, so that it is done in the task context
|
|
// of the caller. Format doc borrowed from PassiveTextLogger.
|
|
const char *severityString = "UNKNOWN";
|
|
switch (severity.e) {
|
|
case Fw::LogSeverity::FATAL:
|
|
severityString = "FATAL";
|
|
break;
|
|
case Fw::LogSeverity::WARNING_HI:
|
|
severityString = "WARNING_HI";
|
|
break;
|
|
case Fw::LogSeverity::WARNING_LO:
|
|
severityString = "WARNING_LO";
|
|
break;
|
|
case Fw::LogSeverity::COMMAND:
|
|
severityString = "COMMAND";
|
|
break;
|
|
case Fw::LogSeverity::ACTIVITY_HI:
|
|
severityString = "ACTIVITY_HI";
|
|
break;
|
|
case Fw::LogSeverity::ACTIVITY_LO:
|
|
severityString = "ACTIVITY_LO";
|
|
break;
|
|
case Fw::LogSeverity::DIAGNOSTIC:
|
|
severityString = "DIAGNOSTIC";
|
|
break;
|
|
default:
|
|
severityString = "SEVERITY ERROR";
|
|
break;
|
|
}
|
|
|
|
// TODO: Add calling task id to format string
|
|
char textStr[FW_INTERNAL_INTERFACE_STRING_MAX_SIZE];
|
|
NATIVE_INT_TYPE stat;
|
|
|
|
if (timeTag.getTimeBase() == TB_WORKSTATION_TIME) {
|
|
|
|
time_t t = timeTag.getSeconds();
|
|
// Using localtime_r prevents any other calls to localtime (from another thread for example) from
|
|
// interfering with our time object before we use it. However, the null pointer check is still needed
|
|
// to ensure a successful call
|
|
tm tm;
|
|
if (localtime_r(&t, &tm) == NULL) {
|
|
return;
|
|
}
|
|
|
|
stat = snprintf(textStr,
|
|
FW_INTERNAL_INTERFACE_STRING_MAX_SIZE,
|
|
"EVENT: (%d) (%04d-%02d-%02dT%02d:%02d:%02d.%03u) %s: %s\n",
|
|
id, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
|
|
tm.tm_min,tm.tm_sec,timeTag.getUSeconds(),
|
|
severityString,text.toChar());
|
|
}
|
|
else {
|
|
|
|
stat = snprintf(textStr,
|
|
FW_INTERNAL_INTERFACE_STRING_MAX_SIZE,
|
|
"EVENT: (%d) (%d:%d,%d) %s: %s\n",
|
|
id,timeTag.getTimeBase(),timeTag.getSeconds(),timeTag.getUSeconds(),severityString,text.toChar());
|
|
}
|
|
|
|
// If there was a error then just return:
|
|
if (stat <= 0) {
|
|
return;
|
|
}
|
|
// If there was string text truncation:
|
|
else if (stat >= FW_INTERNAL_INTERFACE_STRING_MAX_SIZE) {
|
|
// Do nothing
|
|
}
|
|
|
|
// Call internal interface so that everything else is done on component thread,
|
|
// this helps ensure consistent ordering of the printed text:
|
|
Fw::InternalInterfaceString intText(textStr);
|
|
this->TextQueue_internalInterfaceInvoke(intText);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Internal interface handlers
|
|
// ----------------------------------------------------------------------
|
|
|
|
void ActiveTextLoggerComponentImpl::TextQueue_internalInterfaceHandler(const Fw::InternalInterfaceString& text)
|
|
{
|
|
|
|
// Print to console:
|
|
(void) printf("%s",text.toChar());
|
|
|
|
// Print to file if there is one:
|
|
(void) this->m_log_file.write_to_log(text.toChar(), text.length()); // Ignoring return status
|
|
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Helper Methods
|
|
// ----------------------------------------------------------------------
|
|
|
|
bool ActiveTextLoggerComponentImpl::set_log_file(const char* fileName, const U32 maxSize, const U32 maxBackups)
|
|
{
|
|
FW_ASSERT(fileName != NULL);
|
|
|
|
return this->m_log_file.set_log_file(fileName, maxSize, maxBackups);
|
|
}
|
|
|
|
|
|
} // namespace Svc
|