Merge pull request #83 from eadrkir/master
[deliverable/titan.core.git] / core / LoggerPlugin.hh
1 /******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 * Kovacs, Ferenc
11 * Raduly, Csaba
12 * Zalanyi, Balazs Andor
13 * Pandi, Krisztian
14 *
15 ******************************************************************************/
16 #ifndef LOGGER_PLUGIN_HH
17 #define LOGGER_PLUGIN_HH
18
19 #include "Types.h"
20 #include "Logger.hh"
21
22 namespace TitanLoggerApi
23 {
24 class TitanLogEvent;
25 }
26
27 class ILoggerPlugin;
28 class CHARSTRING;
29
30 // Factory functions to create and destroy dynamic logger plug-ins.
31 typedef ILoggerPlugin *(*cb_create_plugin)(void);
32 typedef void (*cb_destroy_plugin)(ILoggerPlugin *plugin);
33
34 class LoggerPlugin
35 {
36 friend class LoggerPluginManager;
37 public:
38 explicit LoggerPlugin(const char *path);
39 explicit LoggerPlugin(cb_create_plugin *create);
40 ~LoggerPlugin();
41
42 void load();
43 void unload();
44 void reset();
45
46 void set_file_name(const char *new_filename_skeleton, bool from_config);
47 void set_component(const component comp, const char *name);
48 void set_append_file(bool new_append_file);
49 void open_file(bool is_first);
50 void close_file();
51 bool set_file_size(int p_size);
52 bool set_file_number(int p_number);
53 bool set_disk_full_action(TTCN_Logger::disk_full_action_t p_disk_full_action);
54 void set_parameter(const char* param_name, const char* param_value);
55
56 int log(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered,
57 bool separate_file, bool use_emergency_mask);
58 inline bool is_log2str_capable() const { return this->is_log2str_capable_; }
59 CHARSTRING log2str(const TitanLoggerApi::TitanLogEvent& event) const;
60 const char *plugin_name() const;
61 bool is_configured() const;
62 void set_configured(bool configured);
63
64 private:
65 explicit LoggerPlugin(const LoggerPlugin&);
66 LoggerPlugin& operator=(const LoggerPlugin&);
67
68 const char *filename() const { return this->filename_; }
69
70 ILoggerPlugin *ref_; // The plug-in instance.
71 void *handle_; // Shared library handle, NULL for static plug-ins.
72 char *filename_; // Linker name of the plug-in, NULL for static plug-ins.
73 cb_create_plugin create_; // Creator of static plug-ins, NULL otherwise.
74 bool is_log2str_capable_; // True if plugin provides log2str().
75 };
76
77 #endif // LOGGER_PLUGIN_HH
This page took 0.032052 seconds and 5 git commands to generate.