Vector kVec;
neolog << "My vector output: " << kVec << endl;
Additionally, engine users can send logging output to different locations by attaching LogSink objects to the LogSource.
neolog.AttachSink( Core::Get()->GetStdoutSink() ); neolog.AttachSink( Core::Get()->GetConsole() );
In most cases, this is all an engine user should need to do. But there may be times when the programmer wants to control what output is sent to stdout and what is sent to the console. Then an extra LogSource will need to be created.
Some logs are more important than others, and so there is the notion of a loglevel. You can specify the importance of your logging output by doing:
neolog << LogLevel( WARNING ) << "This is a warning." << endl << LogLevel( INFO ) << "This is just info." << endl << LogLevel( PANIC ) << "I'm starting to panic." << endl;
This alone doesn't mean much, but each logging target (LogSink) can be told what loglevel to listen for, and when you send something to the log it will only be sent to log sinks that are listening for that loglevel or worse.
Core::Get()->GetStdoutSink().SetLogThreshold( ERROR ); neolog.AttachSink( &Core::Get()->GetStdoutSink() );
neolog << LogLevel( ERROR ) << "Oh, happy days! An error has occured." << endl << LogLevel( WARNING ) << "Why aren't you listening to me?" << endl;
You can also set a log threshold on the log source to filter any log messages streamed to that source (note that if source filters away a message of less severe level than the source threshold, a sink with higher threshold will NOT get the message)
neolog.SetLogThreshold( ERROR );
In this example, only the first line of output will be sent to stdout because loglevel WARNING is below the threshold given to the log sink.
#include "base.h"
#include <ios>
#include <vector>
#include <iostream>
Include dependency graph for logstream.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Namespaces | |
namespace | NeoEngine |