Interface Documentation
Version: invalid
tag_scope.hh
Go to the documentation of this file.
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Triad National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
18 #include <flecsi-config.h>
19 
20 #if defined(FLECSI_ENABLE_FLOG)
21 
22 #include "flecsi/log/state.hh"
23 
24 namespace flecsi {
25 namespace log {
26 
33 struct tag_scope_t {
34  tag_scope_t(size_t tag = 0) : stash_(flog_t::instance().active_tag()) {
35 #if defined(FLOG_ENABLE_DEBUG)
36  std::cerr << FLOG_COLOR_LTGRAY << "FLOG: activating tag " << tag
37  << FLOG_COLOR_PLAIN << std::endl;
38 #endif
39 
40  // Warn users about externally-scoped messages
41  if(!flog_t::instance().initialized()) {
42  std::cerr
43  << FLOG_COLOR_YELLOW << "FLOG: !!!WARNING You cannot use "
44  << "tag guards for externally scoped messages!!! "
45  << "This message will be active if FLOG_ENABLE_EXTERNAL is defined!!!"
46  << FLOG_COLOR_PLAIN << std::endl;
47  } // if
48 
50  } // tag_scope_t
51 
52  ~tag_scope_t() {
53  flog_t::instance().active_tag() = stash_;
54  } // ~tag_scope_t
55 
56 private:
57  size_t stash_;
58 
59 }; // tag_scope_t
60 
61 } // namespace log
62 } // namespace flecsi
63 
64 #endif // FLECSI_ENABLE_FLOG
Definition: tag_scope.hh:33
Definition: flog.hh:47
static flog_t & instance()
Definition: state.hh:73
Definition: control.hh:31
const size_t & active_tag() const
Definition: state.hh:266