| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include <iosfwd> |
| 14 |
|
| 15 |
//----------------------------------------------------------------------------------------------------------- |
| 16 |
|
| 17 |
namespace atlas { |
| 18 |
namespace runtime { |
| 19 |
namespace trace { |
| 20 |
|
| 21 |
class Control { |
| 22 |
public: |
| 23 |
static bool enabled(); |
| 24 |
}; |
| 25 |
|
| 26 |
//----------------------------------------------------------------------------------------------------------- |
| 27 |
|
| 28 |
// Class used to avoid any printing before and after a timer |
| 29 |
class NoLogging { |
| 30 |
public: |
| 31 |
NoLogging(bool state); |
| 32 |
NoLogging(std::ostream& channel); |
| 33 |
|
| 34 |
public: // static methods |
| 35 |
static std::ostream& channel(); |
| 36 |
static bool enabled(); |
| 37 |
static void start(const std::string&) {} |
| 38 |
static void stop(const std::string&, double) {} |
| 39 |
}; |
| 40 |
|
| 41 |
//----------------------------------------------------------------------------------------------------------- |
| 42 |
|
| 43 |
// Class used to print message before and after a timer |
| 44 |
// Example print: |
| 45 |
// timer-name ... |
| 46 |
// timer-name ... done : 5s |
| 47 |
class Logging { |
| 48 |
public: |
| 49 |
Logging(bool state); |
| 50 |
Logging(std::ostream& channel); |
| 51 |
virtual ~Logging(); |
| 52 |
|
| 53 |
public: // static methods |
| 54 |
static std::ostream& channel(); |
| 55 |
static bool enabled(); |
| 56 |
static void start(const std::string& title); |
| 57 |
static void stop(const std::string& title, double seconds); |
| 58 |
|
| 59 |
private: |
| 60 |
std::ostream* previous_state_; |
| 61 |
}; |
| 62 |
|
| 63 |
//----------------------------------------------------------------------------------------------------------- |
| 64 |
|
| 65 |
// Class used to print message only upon end of a timer |
| 66 |
// Example print: |
| 67 |
// timer-name : 5s |
| 68 |
class LoggingResult : public Logging { |
| 69 |
public: |
| 70 |
using Logging::Logging; |
| 71 |
|
| 72 |
public: // static methods |
| 73 |
static void start(const std::string&) {} |
| 74 |
static void stop(const std::string& title, double seconds); |
| 75 |
}; |
| 76 |
|
| 77 |
//----------------------------------------------------------------------------------------------------------- |
| 78 |
|
| 79 |
} // namespace trace |
| 80 |
} // namespace runtime |
| 81 |
} // namespace atlas |