hotspot/src/share/vm/logging/logStream.inline.hpp
author stefank
Mon, 11 Apr 2016 08:51:53 +0200
changeset 37461 b5c955296b75
parent 37460 bda48699fd11
permissions -rw-r--r--
8153659: Create a CHeap backed LogStream class Reviewed-by: brutisso, mlarsson
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37254
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     1
/*
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     4
 *
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     8
 *
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    13
 * accompanied this code).
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    14
 *
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    18
 *
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    21
 * questions.
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    22
 *
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    23
 */
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    24
#ifndef SHARE_VM_LOGGING_LOGSTREAM_INLINE_HPP
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    25
#define SHARE_VM_LOGGING_LOGSTREAM_INLINE_HPP
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    26
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    27
#include "logging/log.hpp"
37255
100d4a515df0 8152711: Create a non-template Log wrapper class
stefank
parents: 37254
diff changeset
    28
#include "logging/logHandle.hpp"
37254
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    29
#include "logging/logStream.hpp"
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    30
#include "memory/resourceArea.hpp"
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    31
#include "utilities/ostream.hpp"
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    32
37461
b5c955296b75 8153659: Create a CHeap backed LogStream class
stefank
parents: 37460
diff changeset
    33
template <class streamClass>
b5c955296b75 8153659: Create a CHeap backed LogStream class
stefank
parents: 37460
diff changeset
    34
inline void LogStreamBase<streamClass>::write(const char* s, size_t len) {
37254
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    35
  if (len > 0 && s[len - 1] == '\n') {
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    36
    _current_line.write(s, len - 1);
37460
bda48699fd11 8153658: Redundant memory copy in LogStreamNoResourceMark
stefank
parents: 37255
diff changeset
    37
    _current_line.write("\0", 1);
37461
b5c955296b75 8153659: Create a CHeap backed LogStream class
stefank
parents: 37460
diff changeset
    38
    _log_handle.print("%s", _current_line.base());
37254
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    39
    _current_line.reset();
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    40
  } else {
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    41
    _current_line.write(s, len);
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    42
  }
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    43
  update_position(s, len);
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    44
}
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    45
8631304f255c 8152637: Create a stack allocatable LogStream class
stefank
parents:
diff changeset
    46
#endif // SHARE_VM_LOGGING_LOGSTREAM_INLINE_HPP