FreeNOS
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
Log Class Referenceabstract

Logging class. More...

#include <Log.h>

Inheritance diagram for Log:
WeakSingleton< Log > DeviceLog KernelLog StdioLog

Public Types

enum  Level {
  Emergency, Alert, Critical, Error,
  Warning, Notice, Info, Debug
}
 Logging level values. More...
 

Public Member Functions

 Log ()
 Constructor. More...
 
virtual ~Log ()
 Destructor. More...
 
Level getMinimumLogLevel ()
 Get the minimum logging level. More...
 
void setMinimumLogLevel (Level level)
 Set the minimum logging level. More...
 
void append (const char *str)
 Append to buffered output. More...
 
void setIdent (const char *ident)
 Set log identity. More...
 
const char * getIdent () const
 Retrieve log identify. More...
 
virtual void terminate () const
 Terminate the program immediately. More...
 
- Public Member Functions inherited from WeakSingleton< Log >
 WeakSingleton (Log *obj)
 Constructor. More...
 

Protected Member Functions

virtual void write (const char *str)=0
 Write to the actual output device. More...
 

Private Member Functions

void flush (const bool force=false)
 Flush internal buffer. More...
 

Private Attributes

Level m_minimumLogLevel
 Minimum log level required to log. More...
 
const char * m_ident
 Identity. More...
 
char m_outputBuffer [LogBufferSize]
 Output line is stored here until written using write() More...
 
Size m_outputBufferWritten
 Number of characters written in the output buffer. More...
 

Static Private Attributes

static const Size LogBufferSize = 512
 Size of the log buffer in bytes. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from WeakSingleton< Log >
static Loginstance ()
 Retrieve the instance. More...
 

Detailed Description

Logging class.

Note
This class is a singleton

Definition at line 96 of file Log.h.

Member Enumeration Documentation

◆ Level

enum Log::Level

Logging level values.

Enumerator
Emergency 
Alert 
Critical 
Error 
Warning 
Notice 
Info 
Debug 

Definition at line 106 of file Log.h.

Constructor & Destructor Documentation

◆ Log()

Log::Log ( )

Constructor.

Definition at line 21 of file Log.cpp.

◆ ~Log()

Log::~Log ( )
virtual

Destructor.

Definition at line 29 of file Log.cpp.

Member Function Documentation

◆ append()

void Log::append ( const char *  str)

Append to buffered output.

Parameters
strString to append to buffer

Definition at line 53 of file Log.cpp.

References flush(), LogBufferSize, m_outputBuffer, and m_outputBufferWritten.

Referenced by Kernel::Kernel(), and operator<<().

◆ flush()

void Log::flush ( const bool  force = false)
private

Flush internal buffer.

This function reads the contents of the internal buffer and writes all available bytes to the actual output device using write().

Parameters
forceTrue to always flush, even without newline at the end of the buffer.
See also
write

Definition at line 72 of file Log.cpp.

References m_outputBuffer, m_outputBufferWritten, and write().

Referenced by append().

◆ getIdent()

const char * Log::getIdent ( ) const

Retrieve log identify.

Returns
Log identity

Definition at line 43 of file Log.cpp.

References m_ident.

◆ getMinimumLogLevel()

Log::Level Log::getMinimumLogLevel ( )

Get the minimum logging level.

Returns
Minimum LogLevel

Definition at line 33 of file Log.cpp.

References m_minimumLogLevel.

Referenced by LogLevelFile::read().

◆ setIdent()

void Log::setIdent ( const char *  ident)

Set log identity.

Parameters
identLog identity

Definition at line 48 of file Log.cpp.

References m_ident.

◆ setMinimumLogLevel()

void Log::setMinimumLogLevel ( Log::Level  level)

Set the minimum logging level.

Definition at line 38 of file Log.cpp.

References m_minimumLogLevel.

Referenced by kernel_main(), main(), Application::run(), and LogLevelFile::write().

◆ terminate()

void Log::terminate ( ) const
virtual

Terminate the program immediately.

Reimplemented in StdioLog, and KernelLog.

Definition at line 82 of file Log.cpp.

◆ write()

virtual void Log::write ( const char *  str)
protectedpure virtual

Write to the actual output device.

Implemented in DeviceLog, StdioLog, and KernelLog.

Referenced by flush().

Field Documentation

◆ LogBufferSize

const Size Log::LogBufferSize = 512
staticprivate

Size of the log buffer in bytes.

Definition at line 101 of file Log.h.

Referenced by append().

◆ m_ident

const char* Log::m_ident
private

Identity.

Definition at line 197 of file Log.h.

Referenced by getIdent(), and setIdent().

◆ m_minimumLogLevel

Level Log::m_minimumLogLevel
private

Minimum log level required to log.

Definition at line 194 of file Log.h.

Referenced by getMinimumLogLevel(), and setMinimumLogLevel().

◆ m_outputBuffer

char Log::m_outputBuffer[LogBufferSize]
private

Output line is stored here until written using write()

Definition at line 200 of file Log.h.

Referenced by append(), and flush().

◆ m_outputBufferWritten

Size Log::m_outputBufferWritten
private

Number of characters written in the output buffer.

Definition at line 203 of file Log.h.

Referenced by append(), and flush().


The documentation for this class was generated from the following files: