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
14 ******************************************************************************/
15 #ifndef LegacyLogger_HH
16 #define LegacyLogger_HH
19 #include "ILoggerPlugin.hh"
20 #include "Charstring.hh"
22 namespace TitanLoggerApi
27 struct component_id_t;
28 struct logfile_data_struct;
30 /// This class is responsible for configuration file parameters: ConsoleMask
31 /// and FileMask as well.
32 class LegacyLogger: public ILoggerPlugin
36 virtual ~LegacyLogger();
37 inline bool is_static() { return true; }
38 inline bool is_log2str_capable() { return true; }
39 CHARSTRING log2str(const TitanLoggerApi::TitanLogEvent& event);
40 void init(const char *options = 0);
43 void fatal_error(const char *err_msg, ...);
45 void log(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered,
46 bool separate_file, bool use_emergency_mask);
47 static char * plugin_specific_settings();
50 explicit LegacyLogger(const LegacyLogger&);
51 LegacyLogger& operator=(const LegacyLogger&);
53 char *get_file_name(size_t idx);
54 void set_file_name(const char *new_filename_skeleton, boolean from_config);
55 bool set_file_size(int p_size);
56 void set_append_file(bool new_append_file);
57 bool set_file_number(int p_number);
58 bool set_disk_full_action(TTCN_Logger::disk_full_action_t p_disk_full_action);
59 void open_file(bool is_first = true);
61 bool log_file(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered);
62 bool log_file_emerg(const TitanLoggerApi::TitanLogEvent& event);
63 bool log_console(const TitanLoggerApi::TitanLogEvent& event,
64 const TTCN_Logger::Severity& severity);
65 bool log_to_file(const char *event_str);
66 void create_parent_directories(const char *path_name);
67 /// Checks for invalid combinations of LogFileSize, LogFileNumber and
69 void chk_logfile_data();
73 size_t logfile_bytes_;
75 size_t logfile_number_;
76 size_t logfile_index_;
77 /** @brief "Format string" for the log file name.
78 * The following format specifiers will be interpreted:
79 * \li \%c -> name of the current testcase (only on PTCs)
80 * \li \%e -> name of executable
82 * \li \%l -> login name
83 * \li \%n -> component name (only on PTCs, optional)
84 * \li \%p -> process id
85 * \li \%r -> component reference
86 * \li \%s -> default suffix (currently: always "log")
87 * \li \%t -> component type (only on PTCs)
88 * \li \%i -> log file index
91 char *filename_skeleton_;
92 TTCN_Logger::disk_full_action_t disk_full_action_;
93 struct timeval disk_full_time_;
95 /// True if `filename_skeleton_' was set from the configuration file.
97 /// True to open the log file and append to it, false to truncate.
100 bool format_c_present_;
101 bool format_t_present_;
102 char *current_filename_;
103 static LegacyLogger *myself;
106 #endif // LegacyLogger_HH