Package org.robwork.sdurw_core
Class LogPtr
- java.lang.Object
-
- org.robwork.sdurw_core.LogPtr
-
public class LogPtr extends java.lang.ObjectPtr stores a pointer and optionally takes ownership of the value.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Log__ref__()Dereferencing operator.LogCPtrcptr()LogWriterdebug()convenience function for getting the LogWriter
that is associated with the debug loglevelLogWriterdebugLog()convenience function for getting the LogWriter
that is associated with the debug loglevelvoiddecreaseTabLevel()Decrease the indentation.voiddelete()Logderef()The pointer stored in the object.booleanequals(Log p)LogWritererror()convenience function for getting the LogWriter
that is associated with the error loglevelLogWritererrorLog()convenience function for getting the LogWriter
that is associated with the error loglevelvoidflush(Log.LogIndex id)Calls flush on the specified log
If the id cannot be found an exception is thrown
voidflushAll()Calls flush on all logsLogWriterget(Log.LogIndex id)Returns the LogWriter that is associated with LogIndex id
If the id is unknown an exception is thrown.
static longgetCPtr(LogPtr obj)LoggetDeref()Member access operator.LogPtrgetInstance()returns the global log instance.intgetLogIndexMask()get the current log maskLogWritergetLogWriter(Log.LogIndex id)Returns the LogWriter that is associated with LogIndex id
If the id is unknown an exception is thrown.
LogWriterPtrgetWriter(Log.LogIndex id)gets the log writer associated to logindex idvoidincreaseTabLevel()Make indentation to make logs easier to read.LogWriterinfo()convenience function for getting the LogWriter
that is associated with the info loglevelLogWriterinfoLog()convenience function for getting the LogWriter
that is associated with the info loglevelbooleanisEnabled(Log.LogIndex idx)Checks if the given LogIndex is enabled.booleanisNull()checks if the pointer is nullbooleanisShared()check if this Ptr has shared ownership or none
ownershipLoglog()convenience function of getInstancevoidremove(Log.LogIndex id)Removes a log
If the id cannot be found an exception is thrown
voidremoveAll()Removes all log writersvoidsetDisable(int mask)Disable log(s) given by log mask.voidsetEnable(int mask)Enable log(s) given by log mask.voidsetLevel(Log.LogIndex loglevel)set the loglevel.voidsetLog(LogPtr log)sets the instance of the log classvoidsetLogIndexMask(int mask)the loglevel is a runtime handle for enabling/disabling
logging to specific loglevels.voidsetWriter(Log.LogIndex id, LogWriterPtr writer)Associates a LogWriter with the LogIndex id.
SetWriter can either be used to redefine an existing log or to create a new
custom output.
Example:
Log::SetWriter(Log::User1, new LogStreamWriter(std::cout)); RW_LOG(Log::User1, "Message send to User log 1");
voidsetWriterForMask(int mask, LogWriterPtr writer)Associates a LogWriter with the logs specified with mask.
SetWriter can either be used to redefine an existing log or to create a new
custom output.
Example:
log.setWriterForMask(Log::InfoMask | Log::DebugMask, new LogStreamWriter(std::cout)); RW_LOG(Log::Info, "Message send to User log 1");
Log.LogIndexMasktoMask(Log.LogIndex idx)Convert a LogIndex to a mask.LogWriterwarning()convenience function for getting the LogWriter
that is associated with the warning loglevelLogWriterwarningLog()convenience function for getting the LogWriter
that is associated with the warning loglevelvoidwrite(Log.LogIndex id, java.lang.String message)Writes message to the log
If the id cannot be found an exception is thrown
voidwrite(Log.LogIndex id, Message message)Writes message to the logwriter associated with LogIndex id
If the id cannot be found an exception is thrown
voidwriteln(Log.LogIndex id, java.lang.String message)Writes message followed by a '\n' to the log
If the id cannot be found an exception is thrown
-
-
-
Constructor Detail
-
LogPtr
public LogPtr(long cPtr, boolean cMemoryOwn)
-
LogPtr
public LogPtr()
Default constructor yielding a NULL-pointer.
-
LogPtr
public LogPtr(Log ptr)
Do not take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
-
-
Method Detail
-
getCPtr
public static long getCPtr(LogPtr obj)
-
delete
public void delete()
-
deref
public Log deref()
The pointer stored in the object.
-
__ref__
public Log __ref__()
Dereferencing operator.
-
getDeref
public Log getDeref()
Member access operator.
-
equals
public boolean equals(Log p)
-
isShared
public boolean isShared()
check if this Ptr has shared ownership or none
ownership- Returns:
- true if Ptr has shared ownership, false if it has no ownership.
-
isNull
public boolean isNull()
checks if the pointer is null- Returns:
- Returns true if the pointer is null
-
cptr
public LogCPtr cptr()
-
toMask
public Log.LogIndexMask toMask(Log.LogIndex idx)
Convert a LogIndex to a mask.- Parameters:
idx- [in] the LogIndex.- Returns:
- the mask enabling the given log level.
-
infoLog
public LogWriter infoLog()
convenience function for getting the LogWriter
that is associated with the info loglevel- Returns:
- info LogWriter
-
warningLog
public LogWriter warningLog()
convenience function for getting the LogWriter
that is associated with the warning loglevel- Returns:
- warning LogWriter
-
errorLog
public LogWriter errorLog()
convenience function for getting the LogWriter
that is associated with the error loglevel- Returns:
- error LogWriter
-
debugLog
public LogWriter debugLog()
convenience function for getting the LogWriter
that is associated with the debug loglevel- Returns:
- debug LogWriter
-
getInstance
public LogPtr getInstance()
returns the global log instance. Global in the sence
of whatever is linked staticly together.- Returns:
- a Log
-
log
public Log log()
convenience function of getInstance- Returns:
- a Log
-
setLog
public void setLog(LogPtr log)
sets the instance of the log class- Parameters:
log- [in] the log that will be used through the static log methods.
-
setLevel
public void setLevel(Log.LogIndex loglevel)
set the loglevel. Any log with LogIndex equal to or less than
loglevel will be enabled. Any log above will be disabled unless an
enabled mask is specified for that log- Parameters:
loglevel- [in] the level
-
getWriter
public LogWriterPtr getWriter(Log.LogIndex id)
gets the log writer associated to logindex id- Parameters:
id- [in] logindex- Returns:
- log writer
-
setWriter
public void setWriter(Log.LogIndex id, LogWriterPtr writer)
Associates a LogWriter with the LogIndex id.
SetWriter can either be used to redefine an existing log or to create a new
custom output.
Example:
Log::SetWriter(Log::User1, new LogStreamWriter(std::cout)); RW_LOG(Log::User1, "Message send to User log 1");
- Parameters:
id- [in] the LogIndex that the logwriter is associated with.writer- [in] LogWriter object to use
-
setWriterForMask
public void setWriterForMask(int mask, LogWriterPtr writer)Associates a LogWriter with the logs specified with mask.
SetWriter can either be used to redefine an existing log or to create a new
custom output.
Example:
log.setWriterForMask(Log::InfoMask | Log::DebugMask, new LogStreamWriter(std::cout)); RW_LOG(Log::Info, "Message send to User log 1");
- Parameters:
mask- [in] the LogIndexMask that the logwriter is associated with.writer- [in] LogWriter object to use
-
get
public LogWriter get(Log.LogIndex id)
Returns the LogWriter that is associated with LogIndex id
If the id is unknown an exception is thrown.
- Parameters:
id- [in] loglevel- Returns:
- Reference to LogWriter object
-
write
public void write(Log.LogIndex id, java.lang.String message)
Writes message to the log
If the id cannot be found an exception is thrown
- Parameters:
id- [in] Log identifiermessage- [in] String message to write
-
write
public void write(Log.LogIndex id, Message message)
Writes message to the logwriter associated with LogIndex id
If the id cannot be found an exception is thrown
- Parameters:
id- [in] Log identifiermessage- [in] Message to write
-
writeln
public void writeln(Log.LogIndex id, java.lang.String message)
Writes message followed by a '\n' to the log
If the id cannot be found an exception is thrown
- Parameters:
id- [in] Log identifiermessage- [in] Message to write
-
flush
public void flush(Log.LogIndex id)
Calls flush on the specified log
If the id cannot be found an exception is thrown
- Parameters:
id- [in] loglevel
-
flushAll
public void flushAll()
Calls flush on all logs
-
remove
public void remove(Log.LogIndex id)
Removes a log
If the id cannot be found an exception is thrown
- Parameters:
id- [in] Log identifier
-
removeAll
public void removeAll()
Removes all log writers
-
increaseTabLevel
public void increaseTabLevel()
Make indentation to make logs easier to read.
-
decreaseTabLevel
public void decreaseTabLevel()
Decrease the indentation.
-
info
public LogWriter info()
convenience function for getting the LogWriter
that is associated with the info loglevel- Returns:
- info LogWriter
-
warning
public LogWriter warning()
convenience function for getting the LogWriter
that is associated with the warning loglevel- Returns:
- info LogWriter
-
error
public LogWriter error()
convenience function for getting the LogWriter
that is associated with the error loglevel- Returns:
- info LogWriter
-
debug
public LogWriter debug()
convenience function for getting the LogWriter
that is associated with the debug loglevel- Returns:
- info LogWriter
-
setLogIndexMask
public void setLogIndexMask(int mask)
the loglevel is a runtime handle for enabling/disabling
logging to specific loglevels.- Parameters:
mask-
Note: DEPRECATED. Use setEnable/setDisable instead
-
getLogIndexMask
public int getLogIndexMask()
get the current log mask- Returns:
- the LogIndex
Note: DEPRECATED. To be removed
-
setEnable
public void setEnable(int mask)
Enable log(s) given by log mask.- Parameters:
mask- [in] the mask for the logs to enable.
-
isEnabled
public boolean isEnabled(Log.LogIndex idx)
Checks if the given LogIndex is enabled. This can be used to
determine if a certain log level will be displayed or not.- Parameters:
idx- [in] the level
-
setDisable
public void setDisable(int mask)
Disable log(s) given by log mask.- Parameters:
mask- [in] the mask for the logs to disable.
-
getLogWriter
public LogWriter getLogWriter(Log.LogIndex id)
Returns the LogWriter that is associated with LogIndex id
If the id is unknown an exception is thrown.
- Parameters:
id- [in] loglevel- Returns:
- Reference to LogWriter object
-
-