2121#include " ../Utils/Logger.h"
2222#include < algorithm>
2323#include < iostream>
24+ #include < memory>
2425#include < sstream>
2526#include < stack>
2627
@@ -135,12 +136,12 @@ Runtime::Runtime() :
135136 internals (new RuntimeInternals(*this ,
136137 EScript::getSGlobals ()->clone(),
137138 std::make_shared<RuntimeInternals::SharedRuntimeContext>())),
138- logger(new LoggerGroup( Logger::LOG_WARNING) ){
139+ logger(Logger::LOG_WARNING){
139140
140141 declareConstant (internals->getGlobals ()," GLOBALS" ,internals->getGlobals ());
141142 declareConstant (internals->getGlobals ()," SGLOBALS" ,EScript::getSGlobals ());
142143
143- logger-> addLogger (" coutLogger" ,new StdLogger (std::cout));
144+ logger. addLogger (" coutLogger" , std::make_shared< StdLogger> (std::cout));
144145 // ctor
145146}
146147
@@ -155,11 +156,7 @@ Runtime::Runtime(const Runtime& other) :
155156}
156157
157158// ! (dtor)
158- Runtime::~Runtime () {
159- // declareConstant(internals->getGlobals(), "GLOBALS",nullptr); //! \todo threading: Remove this and check the effect.
160- internals.reset (nullptr );
161- // dtor
162- }
159+ Runtime::~Runtime () = default ;
163160
164161ERef<Runtime> Runtime::_fork ()const {
165162 return new Runtime (*this );
@@ -247,7 +244,7 @@ size_t Runtime::getStackSize()const { return internals->getStackSize(); }
247244
248245size_t Runtime::_getStackSizeLimit ()const { return internals->_getStackSizeLimit (); }
249246
250- void Runtime::info (const std::string & s) { logger-> info (s); }
247+ void Runtime::info (const std::string & s) { logger. info (s); }
251248
252249void Runtime::setAddStackInfoToExceptions (bool b) { internals->setAddStackInfoToExceptions (b); }
253250
@@ -261,7 +258,7 @@ void Runtime::_setStackSizeLimit(const size_t s) { internals->_setStackSizeLimit
261258
262259void Runtime::setTreatWarningsAsError (bool b){
263260 if (b){ // --> disable coutLogger and add throwLogger
264- Logger * coutLogger = logger-> getLogger (" coutLogger" );
261+ Logger * coutLogger = logger. getLogger (" coutLogger" );
265262 if (coutLogger!=nullptr )
266263 coutLogger->setMinLevel (Logger::LOG_ERROR);
267264
@@ -272,12 +269,12 @@ void Runtime::setTreatWarningsAsError(bool b){
272269 public:
273270 ThrowLogger (Runtime & _rt) : Logger(LOG_PEDANTIC_WARNING,LOG_WARNING), rt(_rt){}
274271 };
275- logger-> addLogger (" throwLogger" ,new ThrowLogger (*this ));
272+ logger. addLogger (" throwLogger" , std::make_shared< ThrowLogger> (*this ));
276273 }else {
277- Logger * coutLogger = logger-> getLogger (" coutLogger" );
274+ Logger * coutLogger = logger. getLogger (" coutLogger" );
278275 if (coutLogger!=nullptr )
279276 coutLogger->setMinLevel (Logger::LOG_ALL);
280- logger-> removeLogger (" throwLogger" );
277+ logger. removeLogger (" throwLogger" );
281278 }
282279}
283280void Runtime::throwException (const std::string & s,Object * obj){ internals->throwException (s,obj); }
@@ -330,22 +327,22 @@ class CountingLogger : public Logger{
330327};
331328
332329void Runtime::enableLogCounting (){
333- if (logger-> getLogger (" countingLogger" )==nullptr )
334- logger-> addLogger (" countingLogger" ,new CountingLogger);
330+ if (logger. getLogger (" countingLogger" )==nullptr )
331+ logger. addLogger (" countingLogger" , std::make_shared< CountingLogger>() );
335332}
336333
337334void Runtime::disableLogCounting (){
338- logger-> removeLogger (" countingLogger" );
335+ logger. removeLogger (" countingLogger" );
339336}
340337
341338void Runtime::resetLogCounter (Logger::level_t level){
342- CountingLogger * l = dynamic_cast <CountingLogger*>(logger-> getLogger (" countingLogger" ));
339+ CountingLogger * l = dynamic_cast <CountingLogger*>(logger. getLogger (" countingLogger" ));
343340 if (l!=nullptr )
344341 l->reset (level);
345342}
346343
347344uint32_t Runtime::getLogCounter (Logger::level_t level)const {
348- CountingLogger * l = dynamic_cast <CountingLogger*>(logger-> getLogger (" countingLogger" ));
345+ auto l = dynamic_cast <const CountingLogger*>(logger. getLogger (" countingLogger" ));
349346 return l==nullptr ? 0 : l->get (level);
350347}
351348
0 commit comments