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