The console class This class manage all the stdio stuff. More...
#include <Console.h>
Public Types | |
enum | ConsoleMode { Verbose = 1 } |
enumaration for the console modes More... | |
enum | FreeCAD_ConsoleMsgType { MsgType_Txt = 1, MsgType_Log = 2, MsgType_Wrn = 4, MsgType_Err = 8 } |
Public Member Functions | |
void | AttachObserver (ConsoleObserver *pcObserver) |
Attaches an Observer to FCConsole. | |
void | DetachObserver (ConsoleObserver *pcObserver) |
Detaches an Observer from FCConsole. | |
virtual void | Error (const char *pMsg,...) |
Prints a error Message. | |
ConsoleObserver * | Get (const char *Name) |
virtual void | Log (const char *pMsg,...) |
Prints a log Message. | |
virtual void | Message (const char *pMsg,...) |
Prints a Message. | |
ConsoleMsgFlags | SetEnabledMsgType (const char *sObs, ConsoleMsgFlags type, bool b) |
Enables or disables message types of a cetain console observer. | |
void | SetMode (ConsoleMode m) |
Change mode. | |
const char * | Time (void) |
Delivers a time/date string. | |
void | UnsetMode (ConsoleMode m) |
Change mode. | |
virtual void | Warning (const char *pMsg,...) |
Prints a warning Message. | |
Static Public Member Functions | |
static ConsoleSingleton & | Instance (void) |
singleton | |
Static Public Attributes | |
static PyMethodDef | Methods [] |
Protected Member Functions | |
ConsoleSingleton (void) | |
virtual | ~ConsoleSingleton () |
Static Protected Member Functions | |
static PyObject * | sPyError (PyObject *self, PyObject *args, PyObject *kwd) |
static PyObject * | sPyGetStatus (PyObject *self, PyObject *args, PyObject *kwd) |
static PyObject * | sPyLog (PyObject *self, PyObject *args, PyObject *kwd) |
static PyObject * | sPyMessage (PyObject *self, PyObject *args, PyObject *kwd) |
static PyObject * | sPySetStatus (PyObject *self, PyObject *args, PyObject *kwd) |
static PyObject * | sPyWarning (PyObject *self, PyObject *args, PyObject *kwd) |
Protected Attributes | |
bool | _bVerbose |
The console class This class manage all the stdio stuff.
This includes Messages, Warnings, Log entries and Errors. The incomming Messages are distributed with the FCConsoleObserver. The FCConsole class itself makes no IO, it's more like a manager.
#include <Base/Console.h> Base::Console().Log("Stage: %d",i);
Definition at line 105 of file Console.h.
ConsoleSingleton::ConsoleSingleton | ( | void | ) | [protected] |
Definition at line 53 of file Console.cpp.
Referenced by Instance().
ConsoleSingleton::~ConsoleSingleton | ( | ) | [protected, virtual] |
Definition at line 59 of file Console.cpp.
void ConsoleSingleton::AttachObserver | ( | ConsoleObserver * | pcObserver | ) |
Attaches an Observer to FCConsole.
Attaches an Observer to Console Use this method to attach a ConsoleObserver derived class to the Console.
After the observer is attached all messages will also forwardet to it.
Definition at line 265 of file Console.cpp.
void ConsoleSingleton::DetachObserver | ( | ConsoleObserver * | pcObserver | ) |
Detaches an Observer from FCConsole.
Detaches an Observer from Console Use this method to detach a ConsoleObserver derived class.
After detaching you can destruct the Observer or reinsert it later.
Definition at line 278 of file Console.cpp.
Referenced by App::Application::destructObserver().
void ConsoleSingleton::Error | ( | const char * | pMsg, | |
... | ||||
) | [virtual] |
Prints a error Message.
Prints a Message This method issues an Error which makes some execution imposible.
Errors are used to get the users attantion. That means in the case FreeCAD running with GUI a Error Message Box is poping up. In console mode a colored message comes out! So dont use this careless. For information purpose the Log or Message method is more aprobiated.
Console().Error("Somthing realy bad in %s happend\n",str);
Definition at line 198 of file Console.cpp.
References format, and format_len.
Referenced by Base::VectorPy::_getattr(), Base::RotationPy::_getattr(), Base::PlacementPy::_getattr(), Base::PersistencePy::_getattr(), Base::MatrixPy::_getattr(), Base::BoundBoxPy::_getattr(), Base::BaseClassPy::_getattr(), Base::VectorPy::_setattr(), Base::RotationPy::_setattr(), Base::PlacementPy::_setattr(), Base::PersistencePy::_setattr(), Base::MatrixPy::_setattr(), Base::BoundBoxPy::_setattr(), Base::BaseClassPy::_setattr(), App::Application::processCmdLineFiles(), Base::XMLReader::readFiles(), Base::Exception::ReportException(), App::PropertyContainer::Restore(), App::PropertyContainer::Save(), sPyError(), Base::VectorPy::staticCallback_add(), Base::BoundBoxPy::staticCallback_add(), Base::PlacementPy::staticCallback_copy(), Base::VectorPy::staticCallback_cross(), Base::MatrixPy::staticCallback_determinant(), Base::VectorPy::staticCallback_distanceToLine(), Base::VectorPy::staticCallback_distanceToPlane(), Base::VectorPy::staticCallback_dot(), Base::BoundBoxPy::staticCallback_enlarge(), Base::BaseClassPy::staticCallback_getAllDerivedFrom(), Base::VectorPy::staticCallback_getAngle(), Base::BoundBoxPy::staticCallback_getIntersectionPoint(), Base::PlacementPy::staticCallback_inverse(), Base::MatrixPy::staticCallback_inverse(), Base::RotationPy::staticCallback_invert(), Base::MatrixPy::staticCallback_invert(), Base::BoundBoxPy::staticCallback_isCutPlane(), Base::BaseClassPy::staticCallback_isDerivedFrom(), Base::BoundBoxPy::staticCallback_isInside(), Base::BoundBoxPy::staticCallback_isIntersection(), Base::PlacementPy::staticCallback_move(), Base::MatrixPy::staticCallback_move(), Base::BoundBoxPy::staticCallback_move(), Base::VectorPy::staticCallback_multiply(), Base::RotationPy::staticCallback_multiply(), Base::PlacementPy::staticCallback_multiply(), Base::MatrixPy::staticCallback_multiply(), Base::RotationPy::staticCallback_multVec(), Base::PlacementPy::staticCallback_multVec(), Base::VectorPy::staticCallback_normalize(), Base::VectorPy::staticCallback_projectToLine(), Base::VectorPy::staticCallback_projectToPlane(), Base::MatrixPy::staticCallback_rotateX(), Base::MatrixPy::staticCallback_rotateY(), Base::MatrixPy::staticCallback_rotateZ(), Base::VectorPy::staticCallback_scale(), Base::MatrixPy::staticCallback_scale(), Base::VectorPy::staticCallback_sub(), Base::RotationPy::staticCallback_toEuler(), Base::PlacementPy::staticCallback_toMatrix(), Base::MatrixPy::staticCallback_transform(), Base::MatrixPy::staticCallback_unity(), and Base::RedirectStdError::sync().
ConsoleObserver * ConsoleSingleton::Get | ( | const char * | Name | ) |
Definition at line 311 of file Console.cpp.
References Base::ConsoleObserver::Name().
Referenced by Base::Builder3D::saveToLog(), SetEnabledMsgType(), sPyGetStatus(), and sPySetStatus().
ConsoleSingleton & ConsoleSingleton::Instance | ( | void | ) | [static] |
singleton
Definition at line 337 of file Console.cpp.
References ConsoleSingleton().
Referenced by Base::Console(), sPyError(), sPyGetStatus(), sPyLog(), sPyMessage(), sPySetStatus(), and sPyWarning().
void ConsoleSingleton::Log | ( | const char * | pMsg, | |
... | ||||
) | [virtual] |
Prints a log Message.
Prints a Message this method is more for devlopment and tracking purpos.
It can be used to track execution of algorithems and functions and put it in files. The normal user dont need to see it, its more for developers and experinced users. So in normal user modes the logging is switched of.
Console().Log("Exectue part %d in algorithem %s\n",i,str);
Definition at line 225 of file Console.cpp.
References _bVerbose, format, and format_len.
Referenced by Base::PyObjectBase::_repr(), App::PropertyFileIncluded::Copy(), Base::Type::createInstanceByName(), App::Application::destruct(), App::Application::processCmdLineFiles(), Base::PyObjectBase::PyObjectBase(), App::Application::runApplication(), Sketcher::Sketch::solve(), sPyLog(), Base::RedirectStdLog::sync(), Base::RedirectStdOutput::sync(), and Base::PyObjectBase::~PyObjectBase().
void ConsoleSingleton::Message | ( | const char * | pMsg, | |
... | ||||
) | [virtual] |
Prints a Message.
Prints a Message This method issues a Message.
Messages are used show some non vital information. That means in the case FreeCAD running with GUI a Message in the status Bar apear. In console mode a message comes out.
Console().Message("Doing somthing important %d times\n",i);
Definition at line 150 of file Console.cpp.
References format, and format_len.
Referenced by sPyMessage().
ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType | ( | const char * | sObs, | |
ConsoleMsgFlags | type, | |||
bool | b | |||
) |
Enables or disables message types of a cetain console observer.
type can be OR'ed with any of the FreeCAD_ConsoleMsgType flags to enable -- if b is true -- or to disable -- if b is false -- a console observer with name sObs.
The return value is an OR'ed value of all message types that have changed their state. For example
// switch off warnings and error messages ConsoleMsgFlags ret = Base::Console().SetEnabledMsgType("myObs", ConsoleMsgType::MsgType_Wrn|ConsoleMsgType::MsgType_Err, false); // do something without notifying observer myObs ... // restore the former configuration again Base::Console().SetEnabledMsgType("myObs", ret, true);
switches off warnings and error messages and restore the state before the modification. If the observer sObs doesn't exist then nothing happens.
Definition at line 103 of file Console.cpp.
References Base::ConsoleObserver::bErr, Base::ConsoleObserver::bLog, Base::ConsoleObserver::bMsg, Base::ConsoleObserver::bWrn, Get(), MsgType_Err, MsgType_Log, MsgType_Txt, and MsgType_Wrn.
void ConsoleSingleton::SetMode | ( | ConsoleMode | m | ) |
PyObject * ConsoleSingleton::sPyError | ( | PyObject * | self, | |
PyObject * | args, | |||
PyObject * | kwd | |||
) | [static, protected] |
Definition at line 434 of file Console.cpp.
References Error(), Instance(), PY_CATCH, and PY_TRY.
PyObject * ConsoleSingleton::sPyGetStatus | ( | PyObject * | self, | |
PyObject * | args, | |||
PyObject * | kwd | |||
) | [static, protected] |
Definition at line 500 of file Console.cpp.
References FemExample::b, Base::ConsoleObserver::bErr, Base::ConsoleObserver::bLog, Base::ConsoleObserver::bMsg, Base::ConsoleObserver::bWrn, Get(), Instance(), PY_CATCH, and PY_TRY.
PyObject * ConsoleSingleton::sPyLog | ( | PyObject * | self, | |
PyObject * | args, | |||
PyObject * | kwd | |||
) | [static, protected] |
Definition at line 467 of file Console.cpp.
References Instance(), Log(), PY_CATCH, and PY_TRY.
PyObject * ConsoleSingleton::sPyMessage | ( | PyObject * | self, | |
PyObject * | args, | |||
PyObject * | kwd | |||
) | [static, protected] |
Definition at line 368 of file Console.cpp.
References Instance(), Message(), PY_CATCH, and PY_TRY.
PyObject * ConsoleSingleton::sPySetStatus | ( | PyObject * | self, | |
PyObject * | args, | |||
PyObject * | kwd | |||
) | [static, protected] |
Definition at line 529 of file Console.cpp.
References Base::ConsoleObserver::bErr, Base::ConsoleObserver::bLog, Base::ConsoleObserver::bMsg, Base::ConsoleObserver::bWrn, Get(), Instance(), PY_CATCH, Py_Error, and PY_TRY.
PyObject * ConsoleSingleton::sPyWarning | ( | PyObject * | self, | |
PyObject * | args, | |||
PyObject * | kwd | |||
) | [static, protected] |
Definition at line 401 of file Console.cpp.
References Instance(), PY_CATCH, PY_TRY, and Warning().
const char * ConsoleSingleton::Time | ( | void | ) |
Delivers a time/date string.
Delivers the time/date this method give you a string with the actual time/date.
You can use that for Log() calls to make time stamps.
Definition at line 243 of file Console.cpp.
void ConsoleSingleton::UnsetMode | ( | ConsoleMode | m | ) |
void ConsoleSingleton::Warning | ( | const char * | pMsg, | |
... | ||||
) | [virtual] |
Prints a warning Message.
Prints a Message This method issues a Warning.
Messages are used to get the users attantion. That means in the case FreeCAD running with GUI a Message Box is poping up. In console mode a colored message comes out! So dont use careless. For information purpose the Log or Message method is more aprobiated.
Console().Warning("Some defects in %s, loading anyway\n",str);
Definition at line 174 of file Console.cpp.
References format, and format_len.
Referenced by Sketcher::Sketch::addDistanceConstraint(), Sketcher::Sketch::addEqualConstraint(), Sketcher::Sketch::addPerpendicularConstraint(), Sketcher::Sketch::addTangentConstraint(), ParameterGrp::Clear(), Base::ConsoleObserverFile::ConsoleObserverFile(), App::Application::processCmdLineFiles(), Base::ScriptFactorySingleton::ProduceScript(), App::PropertyLinkSubList::Restore(), App::PropertyLinkList::Restore(), App::PropertyLinkSub::Restore(), App::PropertyLink::Restore(), Sketcher::Sketch::solve(), sPyWarning(), and Sketcher::Sketch::toShape().
bool Base::ConsoleSingleton::_bVerbose [protected] |
Definition at line 163 of file Console.h.
Referenced by Log(), SetMode(), and UnsetMode().
PyMethodDef ConsoleSingleton::Methods [static] |
{ {"PrintMessage", (PyCFunction) ConsoleSingleton::sPyMessage, 1, "PrintMessage(string) -- Print a message to the output"}, {"PrintLog", (PyCFunction) ConsoleSingleton::sPyLog, 1, "PrintLog(string) -- Print a log message to the output"}, {"PrintError" , (PyCFunction) ConsoleSingleton::sPyError, 1, "PrintError(string) -- Print an error message to the output"}, {"PrintWarning", (PyCFunction) ConsoleSingleton::sPyWarning, 1, "PrintWarning -- Print a warning to the output"}, {"SetStatus", (PyCFunction) ConsoleSingleton::sPySetStatus, 1, "Set the status for either Log, Msg, Wrn or Error for an observer"}, {"GetStatus", (PyCFunction) ConsoleSingleton::sPyGetStatus, 1, "Get the status for either Log, Msg, Wrn or Error for an observer"}, {NULL, NULL, 0, NULL} }