souffle  2.0.2-371-g6315b36
LogStatement.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file LogStatement.h
12  *
13  * Generate log statements for multiple file types.
14  *
15  ***********************************************************************/
16 
17 #include "parser/SrcLocation.h"
18 #include <sstream>
19 #include <string>
20 
21 namespace souffle {
22 
23 class LogStatement {
24 public:
25  static const std::string tNonrecursiveRelation(
26  const std::string& relationName, const SrcLocation& srcLocation) {
27  const char* messageType = "@t-nonrecursive-relation";
28  std::stringstream line;
29  line << messageType << ";" << relationName << ";" << srcLocation << ";";
30  return line.str();
31  }
32  static const std::string tRelationLoadTime(
33  const std::string& relationName, const SrcLocation& srcLocation) {
34  const char* messageType = "@t-relation-loadtime";
35  std::stringstream line;
36  line << messageType << ";" << relationName << ";" << srcLocation << ";loadtime;";
37  return line.str();
38  }
39 
40  static const std::string tRelationSaveTime(
41  const std::string& relationName, const SrcLocation& srcLocation) {
42  const char* messageType = "@t-relation-savetime";
43  std::stringstream line;
44  line << messageType << ";" << relationName << ";" << srcLocation << ";savetime;";
45  return line.str();
46  }
47 
48  static const std::string nNonrecursiveRelation(
49  const std::string& relationName, const SrcLocation& srcLocation) {
50  const char* messageType = "@n-nonrecursive-relation";
51  std::stringstream line;
52  line << messageType << ";" << relationName << ";" << srcLocation << ";";
53  return line.str();
54  }
55 
56  static const std::string tNonrecursiveRule(
57  const std::string& relationName, const SrcLocation& srcLocation, const std::string& datalogText) {
58  const char* messageType = "@t-nonrecursive-rule";
59  std::stringstream line;
60  line << messageType << ";" << relationName << ";" << srcLocation << ";" << datalogText << ";";
61  return line.str();
62  }
63 
64  static const std::string nNonrecursiveRule(
65  const std::string& relationName, const SrcLocation& srcLocation, const std::string& datalogText) {
66  const char* messageType = "@n-nonrecursive-rule";
67  std::stringstream line;
68  line << messageType << ";" << relationName << ";" << srcLocation << ";" << datalogText << ";";
69  return line.str();
70  }
71 
72  static const std::string tRecursiveRule(const std::string& relationName, const int version,
73  const SrcLocation& srcLocation, const std::string& datalogText) {
74  const char* messageType = "@t-recursive-rule";
75  std::stringstream line;
76  line << messageType << ";" << relationName << ";" << version << ";" << srcLocation << ";"
77  << datalogText << ";";
78  return line.str();
79  }
80 
81  static const std::string nRecursiveRule(const std::string& relationName, const int version,
82  const SrcLocation& srcLocation, const std::string& datalogText) {
83  const char* messageType = "@n-recursive-rule";
84  std::stringstream line;
85  line << messageType << ";" << relationName << ";" << version << ";" << srcLocation << ";"
86  << datalogText << ";";
87  return line.str();
88  }
89 
90  static const std::string tRecursiveRelation(
91  const std::string& relationName, const SrcLocation& srcLocation) {
92  const char* messageType = "@t-recursive-relation";
93  std::stringstream line;
94  line << messageType << ";" << relationName << ";" << srcLocation << ";";
95  return line.str();
96  }
97 
98  static const std::string nRecursiveRelation(
99  const std::string& relationName, const SrcLocation& srcLocation) {
100  const char* messageType = "@n-recursive-relation";
101  std::stringstream line;
102  line << messageType << ";" << relationName << ";" << srcLocation << ";";
103  return line.str();
104  }
105 
106  static const std::string cRecursiveRelation(
107  const std::string& relationName, const SrcLocation& srcLocation) {
108  const char* messageType = "@c-recursive-relation";
109  std::stringstream line;
110  line << messageType << ";" << relationName << ";" << srcLocation << ";";
111  return line.str();
112  }
113 
114  static const std::string pProofCounter(
115  const std::string& relationName, const SrcLocation& srcLocation, const std::string& datalogText) {
116  // TODO (#590): the profiler should be modified to use this type of log message, as currently these
117  // messages are ignored
118  const char* messageType = "#p-proof-counter";
119  std::stringstream line;
120  line << messageType << ";" << relationName << ";" << srcLocation << ";" << datalogText << ";";
121  // TODO (#590): the additional semicolon is added to maintain backwards compatibility and should
122  // eventually be removed
123  line << ";";
124  return line.str();
125  }
126 
127  static const std::string runtime() {
128  const char* messageType = "@runtime";
129  std::stringstream line;
130  line << messageType << ";";
131  return line.str();
132  }
133 
134  static const std::string startDebug() {
135  const char* messageType = "@start-debug";
136  std::stringstream line;
137  line << messageType;
138  return line.str();
139  }
140 };
141 
142 } // end of namespace souffle
souffle::LogStatement::nNonrecursiveRule
static const std::string nNonrecursiveRule(const std::string &relationName, const SrcLocation &srcLocation, const std::string &datalogText)
Definition: LogStatement.h:76
souffle::LogStatement::cRecursiveRelation
static const std::string cRecursiveRelation(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:118
SrcLocation.h
souffle::LogStatement::tRecursiveRelation
static const std::string tRecursiveRelation(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:102
souffle::LogStatement::runtime
static const std::string runtime()
Definition: LogStatement.h:139
souffle::LogStatement::startDebug
static const std::string startDebug()
Definition: LogStatement.h:146
souffle::LogStatement::nRecursiveRule
static const std::string nRecursiveRule(const std::string &relationName, const int version, const SrcLocation &srcLocation, const std::string &datalogText)
Definition: LogStatement.h:93
souffle::LogStatement::nRecursiveRelation
static const std::string nRecursiveRelation(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:110
souffle::LogStatement::tNonrecursiveRelation
static const std::string tNonrecursiveRelation(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:37
souffle::LogStatement::tNonrecursiveRule
static const std::string tNonrecursiveRule(const std::string &relationName, const SrcLocation &srcLocation, const std::string &datalogText)
Definition: LogStatement.h:68
souffle::LogStatement::tRelationLoadTime
static const std::string tRelationLoadTime(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:44
souffle::LogStatement::pProofCounter
static const std::string pProofCounter(const std::string &relationName, const SrcLocation &srcLocation, const std::string &datalogText)
Definition: LogStatement.h:126
souffle::LogStatement::nNonrecursiveRelation
static const std::string nNonrecursiveRelation(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:60
souffle::LogStatement::tRecursiveRule
static const std::string tRecursiveRule(const std::string &relationName, const int version, const SrcLocation &srcLocation, const std::string &datalogText)
Definition: LogStatement.h:84
souffle::SrcLocation
A class describing a range in an input file.
Definition: SrcLocation.h:32
souffle
Definition: AggregateOp.h:25
souffle::LogStatement::tRelationSaveTime
static const std::string tRelationSaveTime(const std::string &relationName, const SrcLocation &srcLocation)
Definition: LogStatement.h:52