Class LogPtr


  • public class LogPtr
    extends java.lang.Object
    Ptr stores a pointer and optionally takes ownership of the value.
    • Constructor Summary

      Constructors 
      Constructor Description
      LogPtr()
      Default constructor yielding a NULL-pointer.
      LogPtr​(long cPtr, boolean cMemoryOwn)  
      LogPtr​(Log ptr)
      Do not take ownership of ptr.

      ptr can be null.

      The constructor is implicit on purpose.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Log __ref__()
      Dereferencing operator.
      LogCPtr cptr()  
      LogWriter debug()
      convenience function for getting the LogWriter
      that is associated with the debug loglevel
      LogWriter debugLog()
      convenience function for getting the LogWriter
      that is associated with the debug loglevel
      void decreaseTabLevel()
      Decrease the indentation.
      void delete()  
      Log deref()
      The pointer stored in the object.
      boolean equals​(Log p)  
      LogWriter error()
      convenience function for getting the LogWriter
      that is associated with the error loglevel
      LogWriter errorLog()
      convenience function for getting the LogWriter
      that is associated with the error loglevel
      void flush​(Log.LogIndex id)
      Calls flush on the specified log

      If the id cannot be found an exception is thrown

      void flushAll()
      Calls flush on all logs
      LogWriter get​(Log.LogIndex id)
      Returns the LogWriter that is associated with LogIndex id

      If the id is unknown an exception is thrown.

      static long getCPtr​(LogPtr obj)  
      Log getDeref()
      Member access operator.
      LogPtr getInstance()
      returns the global log instance.
      int getLogIndexMask()
      get the current log mask
      LogWriter getLogWriter​(Log.LogIndex id)
      Returns the LogWriter that is associated with LogIndex id

      If the id is unknown an exception is thrown.

      LogWriterPtr getWriter​(Log.LogIndex id)
      gets the log writer associated to logindex id
      void increaseTabLevel()
      Make indentation to make logs easier to read.
      LogWriter info()
      convenience function for getting the LogWriter
      that is associated with the info loglevel
      LogWriter infoLog()
      convenience function for getting the LogWriter
      that is associated with the info loglevel
      boolean isEnabled​(Log.LogIndex idx)
      Checks if the given LogIndex is enabled.
      boolean isNull()
      checks if the pointer is null
      boolean isShared()
      check if this Ptr has shared ownership or none
      ownership
      Log log()
      convenience function of getInstance
      void remove​(Log.LogIndex id)
      Removes a log

      If the id cannot be found an exception is thrown

      void removeAll()
      Removes all log writers
      void setDisable​(int mask)
      Disable log(s) given by log mask.
      void setEnable​(int mask)
      Enable log(s) given by log mask.
      void setLevel​(Log.LogIndex loglevel)
      set the loglevel.
      void setLog​(LogPtr log)
      sets the instance of the log class
      void setLogIndexMask​(int mask)
      the loglevel is a runtime handle for enabling/disabling
      logging to specific loglevels.
      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");

      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");

      Log.LogIndexMask toMask​(Log.LogIndex idx)
      Convert a LogIndex to a mask.
      LogWriter warning()
      convenience function for getting the LogWriter
      that is associated with the warning loglevel
      LogWriter warningLog()
      convenience function for getting the LogWriter
      that is associated with the warning loglevel
      void write​(Log.LogIndex id, java.lang.String message)
      Writes message to the log

      If the id cannot be found an exception is thrown

      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


      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

      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • 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 identifier
        message - [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 identifier
        message - [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 identifier
        message - [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