Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | // All rights reserved. This program and the accompanying materials | |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef TSTLogger_HH | |
9 | #define TSTLogger_HH | |
10 | ||
11 | #include <string> | |
12 | #include <map> | |
13 | ||
14 | namespace TitanLoggerApi | |
15 | { | |
16 | class TitanLogEvent; | |
17 | class TimestampType; | |
18 | class QualifiedName; | |
19 | class TestcaseType; | |
20 | class VerdictOp; | |
21 | } | |
22 | ||
23 | class ILoggerPlugin; | |
24 | ||
25 | struct ParameterData | |
26 | { | |
27 | std::string default_value; | |
28 | bool optional; | |
29 | std::string description; | |
30 | bool set; | |
31 | std::string value; | |
32 | ParameterData(): optional(false), set(false) {} | |
33 | ParameterData(const std::string& def_val, const bool opt=true, const std::string& descr=""): | |
34 | default_value(def_val), optional(opt), description(descr), set(false) {} | |
35 | void set_value(std::string v) { set=true; value=v; } | |
36 | std::string get_value() { return set ? value : default_value; } | |
37 | }; | |
38 | ||
39 | class TSTLogger: public ILoggerPlugin | |
40 | { | |
41 | public: | |
42 | explicit TSTLogger(); | |
43 | virtual ~TSTLogger(); | |
44 | inline bool is_static() { return false; } | |
45 | void init(const char *options = NULL); | |
46 | void fini(); | |
47 | ||
48 | void log(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered); | |
49 | void log(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered, bool separate_file, bool use_emergency_mask); | |
50 | void set_parameter(const char *parameter_name, const char *parameter_value); | |
51 | ||
52 | private: | |
53 | std::string user_agent; // HTTP req. parameter value | |
54 | std::map<std::string,ParameterData> parameters; // plugin parameters | |
55 | ||
56 | std::string suite_id_; | |
57 | std::string tcase_id_; | |
58 | int testcase_count_; | |
59 | ||
60 | explicit TSTLogger(const TSTLogger&); | |
61 | TSTLogger& operator=(const TSTLogger&); | |
62 | ||
63 | bool log_plugin_debug(); | |
64 | ||
65 | static std::string get_tst_time_str(const TitanLoggerApi::TimestampType& timestamp); | |
66 | static std::string get_host_name(); | |
67 | static std::string get_user_name(); | |
68 | ||
69 | void add_database_params(std::map<std::string,std::string>& req_params); | |
70 | std::string post_message(std::map<std::string,std::string> req_params, const std::string& TST_service_uri); | |
71 | ||
72 | bool is_main_proc() const; | |
73 | ||
74 | void log_testcase_start(const TitanLoggerApi::QualifiedName& testcaseStarted, const TitanLoggerApi::TimestampType& timestamp); | |
75 | void log_testcase_stop(const TitanLoggerApi::TestcaseType& testcaseFinished, const TitanLoggerApi::TimestampType& timestamp); | |
76 | void log_testsuite_stop(const TitanLoggerApi::TimestampType& timestamp); | |
77 | void log_testsuite_start(const TitanLoggerApi::TimestampType& timestamp); | |
78 | void log_verdictop_reason(const TitanLoggerApi::VerdictOp& verdictOp); | |
79 | }; | |
80 | ||
81 | #endif // TSTLogger_HH |