< prev index next >

src/share/vm/logging/logStream.hpp

Print this page
rev 13105 : imported patch 8181917-refactor-ul-logstream-alt1-callsite-changes


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_LOGGING_LOGSTREAM_HPP
  26 #define SHARE_VM_LOGGING_LOGSTREAM_HPP
  27 
  28 #include "logging/log.hpp"
  29 #include "logging/logHandle.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "utilities/ostream.hpp"
  32 



  33 // The base class of an output stream that logs to the logging framework.
  34 template <class streamClass>
  35 class LogStreamBase : public outputStream {
  36   streamClass     _current_line;
  37   LogTargetHandle _log_handle;
  38 
  39 public:
  40   // Constructor to support creation from a LogTarget instance.
  41   //
  42   // LogTarget(Debug, gc) log;
  43   // LogStreamBase(log) stream;
  44   template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
  45   LogStreamBase(const LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>& type_carrier) :
  46       _log_handle(level, &LogTagSetMapping<T0, T1, T2, T3, T4>::tagset()) {}
  47 
  48   // Constructor to support creation from typed (likely NULL) pointer. Mostly used by the logging framework.
  49   //
  50   // LogStreamBase stream(log.debug());
  51   //  or
  52   // LogStreamBase stream((LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>*)NULL);


 104 //
 105 // The backing buffer is allocated in CHeap memory.
 106 typedef LogStreamBase<bufferedStream> LogStreamCHeap;
 107 
 108 // An output stream that logs to the logging framework, and embeds a ResourceMark.
 109 //
 110 // The backing buffer is allocated in Resource memory.
 111 // The class is intended to be stack allocated.
 112 // The class provides its own ResourceMark,
 113 //  so care needs to be taken when nested ResourceMarks are used.
 114 typedef LogStreamBase<stringStreamWithResourceMark> LogStream;
 115 
 116 // Support creation of a LogStream without having to provide a LogTarget pointer.
 117 #define LogStreamHandle(level, ...) LogStreamTemplate<LogLevel::level, LOG_TAGS(__VA_ARGS__)>
 118 
 119 template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
 120 class LogStreamTemplate : public LogStream {
 121 public:
 122   LogStreamTemplate() : LogStream((LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>*)NULL) {}
 123 };

 124 
 125 #endif // SHARE_VM_LOGGING_LOGSTREAM_HPP


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_LOGGING_LOGSTREAM_HPP
  26 #define SHARE_VM_LOGGING_LOGSTREAM_HPP
  27 
  28 #include "logging/log.hpp"
  29 #include "logging/logHandle.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "utilities/ostream.hpp"
  32 
  33 
  34 
  35 
  36 // The base class of an output stream that logs to the logging framework.
  37 template <class streamClass>
  38 class LogStreamBase : public outputStream {
  39   streamClass     _current_line;
  40   LogTargetHandle _log_handle;
  41 
  42 public:
  43   // Constructor to support creation from a LogTarget instance.
  44   //
  45   // LogTarget(Debug, gc) log;
  46   // LogStreamBase(log) stream;
  47   template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
  48   LogStreamBase(const LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>& type_carrier) :
  49       _log_handle(level, &LogTagSetMapping<T0, T1, T2, T3, T4>::tagset()) {}
  50 
  51   // Constructor to support creation from typed (likely NULL) pointer. Mostly used by the logging framework.
  52   //
  53   // LogStreamBase stream(log.debug());
  54   //  or
  55   // LogStreamBase stream((LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>*)NULL);


 107 //
 108 // The backing buffer is allocated in CHeap memory.
 109 typedef LogStreamBase<bufferedStream> LogStreamCHeap;
 110 
 111 // An output stream that logs to the logging framework, and embeds a ResourceMark.
 112 //
 113 // The backing buffer is allocated in Resource memory.
 114 // The class is intended to be stack allocated.
 115 // The class provides its own ResourceMark,
 116 //  so care needs to be taken when nested ResourceMarks are used.
 117 typedef LogStreamBase<stringStreamWithResourceMark> LogStream;
 118 
 119 // Support creation of a LogStream without having to provide a LogTarget pointer.
 120 #define LogStreamHandle(level, ...) LogStreamTemplate<LogLevel::level, LOG_TAGS(__VA_ARGS__)>
 121 
 122 template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
 123 class LogStreamTemplate : public LogStream {
 124 public:
 125   LogStreamTemplate() : LogStream((LogTargetImpl<level, T0, T1, T2, T3, T4, GuardTag>*)NULL) {}
 126 };
 127 
 128 
 129 #endif // SHARE_VM_LOGGING_LOGSTREAM_HPP
< prev index next >