Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
StandaloneTraceMessage.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* StandaloneTraceMessage.h (C) 2000-2025 */
9/* */
10/* Trace message independent of 'ITraceMng'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_TRACE_STANDALONETRACEMESSAGE_H
13#define ARCCORE_TRACE_STANDALONETRACEMESSAGE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/trace/TraceMessage.h"
18
19#include <sstream>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \brief Management of a standalone message.
32 */
33class ARCCORE_TRACE_EXPORT StandaloneTraceMessage
34{
35 public:
36
37 StandaloneTraceMessage() = default;
38 StandaloneTraceMessage(Trace::eMessageType, int level = TraceMessage::DEFAULT_LEVEL);
39 StandaloneTraceMessage(const TraceMessage& from);
40 StandaloneTraceMessage& operator=(const StandaloneTraceMessage& from);
41
42 public:
43
44 std::ostream& file() const { return m_stream; }
45 Trace::eMessageType type() const { return m_type; }
46 int level() const { return m_level; }
47 int color() const { return m_color; }
48
49 public:
50
51 std::string value() const { return m_stream.str(); }
52
53 private:
54
55 //! Stream to which the message is sent
56 mutable std::ostringstream m_stream;
57 //! Message type
58 Trace::eMessageType m_type = Trace::Normal;
59 //! Message level
60 int m_level = TraceMessage::DEFAULT_LEVEL;
61
62 public:
63
64 //! Message color.
65 mutable int m_color = 0;
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71inline const StandaloneTraceMessage&
73{
74 o.m_color = c.m_color;
75 return o;
76}
77
78template <class T> inline const StandaloneTraceMessage&
79operator<<(const StandaloneTraceMessage& o, const T& v)
80{
81 o.file() << v;
82 return o;
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88} // namespace Arcane
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93#endif
Management of a standalone message.
eMessageType
Stream on which messages are sent.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Output operator for a stream.