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
17 * Szabo, Janos Zoltan – initial implementation
18 * Zalanyi, Balazs Andor
21 ******************************************************************************/
35 class LoggerPluginManager;
37 struct logging_setting_t;
39 /** @brief Logger class
41 Acts as a namespace. No instance data or methods.
46 friend class LoggerPlugin;
47 friend class LoggerPluginManager;
49 static LoggerPluginManager *plugins_;
50 // TODO: This should be plug-in specific, but the configuration file parsers
51 // are using this type...
52 enum disk_full_action_type_t { DISKFULL_ERROR, DISKFULL_STOP,
53 DISKFULL_RETRY, DISKFULL_DELETE };
54 struct disk_full_action_t {
55 disk_full_action_type_t type;
56 size_t retry_interval;
58 enum timestamp_format_t { TIMESTAMP_TIME, TIMESTAMP_DATETIME,
60 enum source_info_format_t { SINFO_NONE, SINFO_SINGLE, SINFO_STACK };
61 enum log_event_types_t { LOGEVENTTYPES_NO, LOGEVENTTYPES_YES,
62 LOGEVENTTYPES_SUBCATEGORIES };
64 enum emergency_logging_behaviour_t { BUFFER_ALL, BUFFER_MASKED };
66 enum matching_verbosity_t { VERBOSITY_COMPACT, VERBOSITY_FULL };
67 enum extcommand_t { EXTCOMMAND_START, EXTCOMMAND_SUCCESS };
69 /** Values and templates can be logged in the following formats */
70 enum data_log_format_t { LF_LEGACY, LF_TTCN };
72 /** @brief Titan logging severities
74 @note The values are not bit masks. Expressions like
75 @code LOG_ALL | TTCN_DEBUG @endcode will not work correctly.
77 @note This enum must start at 0 and have no gaps until
78 NUMBER_OF_LOGSEVERITIES.
82 NOTHING_TO_LOG = 0, // for compatibility
89 DEFAULTOP_UNQUALIFIED, //5
96 EXECUTOR_COMPONENT, //10
101 FUNCTION_UNQUALIFIED,
106 PARALLEL_UNQUALIFIED,
109 TESTCASE_FINISH, //20
110 TESTCASE_UNQUALIFIED,
120 PORTEVENT_MMSEND, //30
125 PORTEVENT_UNQUALIFIED, //35
128 STATISTICS_UNQUALIFIED,
139 VERDICTOP_GETVERDICT, //45
140 VERDICTOP_SETVERDICT,
142 VERDICTOP_UNQUALIFIED,
146 // MATCHING and DEBUG should be at the end (not included in LOG_ALL)
152 MATCHING_PMUNSUCC, //55
157 MATCHING_PROBLEM, //60
158 MATCHING_UNQUALIFIED,
164 DEBUG_UNQUALIFIED, //66
166 NUMBER_OF_LOGSEVERITIES, // must follow the last individual severity
169 /// Number of main severities (plus one, because it includes LOG_NOTHING).
170 static const size_t number_of_categories = 16;
171 /// Main severity names.
172 static const char* severity_category_names[number_of_categories];
173 /// Sub-category suffixes.
174 static const char* severity_subcategory_names[NUMBER_OF_LOGSEVERITIES];
175 static const TTCN_Logger::Severity sev_categories[number_of_categories];
177 static const unsigned int major_version = 2;
178 static const unsigned int minor_version = 2;
180 // buffer used by the log match algorithms to buffer the output
181 static char* logmatch_buffer;
182 // length of the logmatch buffer
183 static size_t logmatch_buffer_len;
184 // the size of the log match buffer (memory allocated for it)
185 static size_t logmatch_buffer_size;
186 // true if the logmatch buffer was already printed in the actual log event.
187 static boolean logmatch_printed;
189 // length of the emergencylogging buffer
190 static size_t emergency_logging;
191 static void set_emergency_logging(size_t size);
192 static size_t get_emergency_logging();
194 static emergency_logging_behaviour_t emergency_logging_behaviour;
195 static void set_emergency_logging_behaviour(emergency_logging_behaviour_t behaviour);
196 static emergency_logging_behaviour_t get_emergency_logging_behaviour();
198 static boolean emergency_logging_for_fail_verdict;
199 static void set_emergency_logging_for_fail_verdict(boolean b);
200 static boolean get_emergency_logging_for_fail_verdict();
202 /** @brief returns the actual length of the logmatch buffer
203 This way it can be stored for later, when the buffer needs to be reverted.
206 static size_t get_logmatch_buffer_len();
208 /** @brief sets the length of the logmatch buffer
209 Is used to effectively revert the buffer to a previous state.
210 @param new_size the new length to be set.
212 static void set_logmatch_buffer_len(size_t new_size);
214 /** @brief prints the contents of the logmatch buffer to the current event
215 Writes contents of the logmatch buffer into the actual event, prefixed with
218 static void print_logmatch_buffer();
220 /** @brief Format a string into the current logmatch buffer.
221 @param fmt_str printf-style format string
224 static void log_logmatch_info(const char *fmt_str, ...)
225 __attribute__ ((__format__ (__printf__, 1, 2)));
227 struct log_mask_struct; // Forward declaration.
229 static log_mask_struct console_log_mask;
230 static log_mask_struct file_log_mask;
231 static log_mask_struct emergency_log_mask;
234 static matching_verbosity_t matching_verbosity;
236 static timestamp_format_t timestamp_format;
238 static source_info_format_t source_info_format;
240 static log_event_types_t log_event_types;
242 static struct timeval start_time;
244 static char *executable_name;
246 static boolean log_entity_name;
248 static data_log_format_t data_log_format;
250 /// Always return the single instance of the LoggerPluginManager.
251 static LoggerPluginManager *get_logger_plugin_manager();
252 /// Returns the actual global logger options. The returned string must be
253 /// freed by the caller.
254 static char *get_logger_settings_str();
257 /** @brief Initialize the logger.
259 @pre initialize_logger has not been called previously
261 static void initialize_logger();
263 /// Frees any resources held by the logger.
264 static void terminate_logger();
266 static bool is_logger_up();
268 /** @brief Initializes the logger configuration.
270 \li sets the logfilename template
271 \li sets \c file_mask to LOG_ALL
272 \li sets \c console_mask to TTCN_ERROR | TTCN_WARNING | TTCN_ACTION | TTCN_TESTCASE | TTCN_STATISTICS
273 \li sets \c timestamp_format = TIMESTAMP_TIME;
274 \li sets \c source_info_format = SINFO_NONE;
275 \li sets \c log_event_types = LOGEVENTTYPES_NO;
276 \li sets \c append_file = FALSE;
277 \li sets \c log_entity_name = FALSE;
279 @pre initialize_logger() has been called.
282 static void reset_configuration();
284 /** @name Setting internal members
287 /** @brief Sets executable_name.
289 \p argv_0 is stripped of its extension and path (if any) and the result is
290 assigned to \c executable_name.
292 @param argv_0 string containing the name of the program ( \c argv[0] )
294 static void set_executable_name(const char *argv_0);
295 static inline char *get_executable_name() { return executable_name; }
297 static data_log_format_t get_log_format() { return data_log_format; }
298 static void set_log_format(data_log_format_t p_data_log_format) { data_log_format = p_data_log_format; }
300 static bool add_parameter(const logging_setting_t& logging_param);
301 static void set_plugin_parameters(component component_reference, const char* component_name);
302 static void load_plugins(component component_reference, const char* component_name);
304 /** @brief Set the log filename skeleton.
306 @param new_filename_skeleton this string is copied to \c filename_skeleton
307 @param from_config TRUE if set from config file value
309 static void set_file_name(const char *new_filename_skeleton,
310 boolean from_config = TRUE);
312 /// Sets start_time by calling \c gettimeofday()
313 static void set_start_time();
315 /** @brief Set the logging mask to a log file.
317 The mask is simply stored internally.
320 @param cmpt a component_id_t identifying the component.
321 @param new_file_mask a \c LoggingBits containing the categories
322 to be logged to a file.
324 static void set_file_mask(component_id_t const& cmpt,
325 const Logging_Bits& new_file_mask);
327 /** @brief Set the logging mask to the console.
329 The mask is simply stored internally.
332 @param cmpt a component_id_t identifying the component.
333 @param new_console_mask a \c LoggingBits containing the categories to be
334 logged to the console.
336 static void set_console_mask(component_id_t const& cmpt,
337 const Logging_Bits& new_console_mask);
339 /** @brief Set the logging mask to the console.
341 The mask is simply stored internally.
344 @param cmpt a component_id_t identifying the component.
345 @param new_logging_mask
347 static void set_emergency_logging_mask(component_id_t const& cmpt,
348 const Logging_Bits& new_logging_mask);
351 static Logging_Bits const& get_file_mask();
353 static Logging_Bits const& get_console_mask();
355 static Logging_Bits const& get_emergency_logging_mask();
357 static void set_timestamp_format(timestamp_format_t new_timestamp_format);
358 static inline timestamp_format_t get_timestamp_format()
359 { return timestamp_format; }
360 static void set_source_info_format(source_info_format_t new_source_info_format);
361 static inline source_info_format_t get_source_info_format()
362 { return source_info_format; }
363 static void set_log_event_types(log_event_types_t new_log_event_types);
364 static inline log_event_types_t get_log_event_types()
365 { return log_event_types; }
366 static void set_append_file(boolean new_append_file);
367 static void set_log_entity_name(boolean new_log_entity_name);
370 static CHARSTRING get_timestamp_str(timestamp_format_t p_timestamp_format);
371 static CHARSTRING get_source_info_str(source_info_format_t p_source_info_format);
372 static boolean get_log_entity_name() { return log_entity_name; }
373 static char *mputstr_severity(char *str, const TTCN_Logger::Severity& sev);
374 static char *mputstr_timestamp(char *str,
375 timestamp_format_t p_timestamp_format,
376 const struct timeval *tv);
377 // Register a logger plug-in into the LoggerPluginManager from the
378 // configuration file.
379 static void register_plugin(const component_id_t comp, char *identifier, char *filename);
381 static bool set_file_size(component_id_t const& comp, int p_size);
382 static bool set_file_number(component_id_t const& comp, int p_number);
383 static bool set_disk_full_action(component_id_t const& comp,
384 disk_full_action_t p_disk_full_action);
386 /** @brief Whether a message with the given severity should be logged to the
389 Checks the actual logging bits selected by set_component()
391 @param sev logging severity
392 @return \c true if it should be logged, \c false otherwise
394 static boolean should_log_to_file(Severity sev);
396 /// Like should_log_to_file() but for logging to the console.
397 static boolean should_log_to_console(Severity sev);
399 /// Like should_log_to_file() but for logging to the emergency.
400 static boolean should_log_to_emergency(Severity sev);
402 /** @brief Get the log event mask.
404 @deprecated Please use TTCN_Logger::should_log_to_file() or
405 TTCN_Logger::should_log_to_console() instead.
407 static unsigned int get_mask();
409 static matching_verbosity_t get_matching_verbosity();
410 static void set_matching_verbosity(matching_verbosity_t v);
412 /** @brief Handle logging of the logger's configuration settings.
414 This function is called from Single_main.cc and Runtime.cc immediately
415 after the "Host controller/Executor/Component started" message.
416 However, in some cases (e.g. in the HC) the logger's settings aren't known yet
417 so the content of the log message cannot be determined.
418 In this situation, an empty log message is stored until the configuration
419 is received, then the stored message is updated before writing.
420 This method performs all three of these operations.
422 @param opening true if called from TTCN_Logger::open_file() while writing
423 the buffered messages, false otherwise.
425 static void write_logger_settings(bool opening = false);
427 /** @brief Opens the log file.
429 Opens the file with the name returned by get_filename(). If append_file
430 is true, new events are written to the end of an existing log file.
431 Otherwise, the log file is truncated.
432 If there are buffered events, they are written to the file.
434 static void open_file();
435 static void close_file();
436 /** @brief dump all events from ring buffer to log file
437 @param do_close_file if true, close the files afterwards
439 static void ring_buffer_dump(bool do_close_file);
441 /** @brief Should this event be logged?
443 @return \c true if the the event with severity specified by
444 \p event_severity should be logged to either the console or the log file,
447 If the logger was not configured yet, it returns true. Otherwise, it
448 masks \p event_severity with console_mask and, if the log file is opened,
451 static boolean log_this_event(Severity event_severity);
453 /** @brief Format and log a message.
457 @param msg_severity severity
458 @param fmt_str printf-style format string
461 static void log(Severity msg_severity, const char *fmt_str, ...)
462 __attribute__ ((__format__ (__printf__, 2, 3) /*, deprecated (one day) */ ));
464 /** @brief Sends the current event string as an error message to the MC.
466 static void send_event_as_error();
468 static void fatal_error(const char *err_msg, ...)
469 __attribute__ ((__format__ (__printf__, 1, 2),
472 /** @brief Log a string without formatting.
476 @param msg_severity severity
477 @param str_ptr the string
480 static void log_str(Severity msg_severity, const char *str_ptr );
482 /** @brief Format and log a list of arguments.
486 @param msg_severity severity
487 @param fmt_str printf-style format string
488 @param p_var variable arguments
491 static void log_va_list(Severity msg_severity, const char *fmt_str,
494 /** @brief Begin an event
496 Events are held on a stack; the new event becomes the current event.
498 If the logger is not yet initialized, this function does nothing.
500 @param msg_severity severity
503 static void begin_event(Severity msg_severity, boolean log2str = FALSE);
505 /** begin an event that logs to CHARSTRING */
506 static void begin_event_log2str() { begin_event(USER_UNQUALIFIED, TRUE); }
510 @pre current_event != NULL
512 This is when the event is actually logged.
516 static void end_event();
518 static CHARSTRING end_event_log2str();
520 /** @brief Finish event.
522 @pre current_event != NULL
526 static void finish_event();
528 /** @brief Format a string into the current event.
530 @pre current_event != NULL
532 @param fmt_str printf-style format string
535 static void log_event(const char *fmt_str, ...)
536 __attribute__ ((__format__ (__printf__, 1, 2)));
538 /** @brief Log event str
540 Stores a string in the current log event without formatting.
542 @pre current_event != NULL
544 @param str_ptr the message
547 static void log_event_str(const char *str_ptr);
549 /** @brief Format a list of arguments into the current event.
551 @pre current_event != NULL
553 Increases the current event's buffer as needed.
555 @param fmt_str printf-style format string
556 @param p_var variable arguments
559 static void log_event_va_list(const char *fmt_str, va_list p_var);
561 // Log an unbound/uninitialized/enum value according to the current format setting
562 static void log_event_unbound();
563 static void log_event_uninitialized();
564 static void log_event_enum(const char* enum_name_str, int enum_value);
566 /** @brief Log one character into the current event.
568 @pre current_event != NULL
570 Appends the character \c c to the buffer of the current event.
572 @param c the character
575 static void log_char(char c);
577 /// Return \c true if \c c is a printable character, \c false otherwise.
578 static boolean is_printable(unsigned char c);
580 /** @brief Log a char.
584 @param c the character
587 static void log_char_escaped(unsigned char c);
589 /** @brief Log a char into expstring_t buffer.
593 @param c the character
594 @param p_buffer expstring_t buffer
597 static void log_char_escaped(unsigned char c, char*& p_buffer);
606 static void log_hex(unsigned char nibble);
608 /** @brief Log an octet.
615 static void log_octet(unsigned char octet);
617 /** @brief Synonymous to log_char.
624 static inline void log_event(char c) { log_char(c); }
626 /** @brief Log the OS error based on the current errno.
630 static void OS_error();
632 // To preserve the semantic meaning of the log messages...
633 /** @name New, one-per-event log functions
634 * @{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
635 static void log_timer_read(const char *timer_name, double start_val);
636 static void log_timer_start(const char *timer_name, double start_val);
637 static void log_timer_guard(double start_val);
638 static void log_timer_stop(const char *timer_name, double stop_val);
639 static void log_timer_timeout(const char *timer_name, double timeout_val);
640 static void log_timer_any_timeout();
641 static void log_timer_unqualified(const char *message);
643 static void log_setverdict(verdicttype new_verdict, verdicttype old_verdict,
644 verdicttype local_verdict, const char *old_reason = NULL, const char *new_reason = NULL);
645 static void log_getverdict(verdicttype verdict);
646 // Handle all VERDICTOP_FINAL events. ptc_verdict/new_verdict are used only
647 // for detailed PTC statistics, in all other cases they're the same.
648 // - is_ptc: true if we're setting the final verdict for a PTC, false for MTC
649 // - ptc_verdict: final verdict of the PTC
650 // - local_verdict: the local verdict until now
651 // - new_verdict: new verdict after PTC is finished
652 // - verdict_reason: final verdict reason for PTC/MTC if applicable
653 // - notification: enumeration value for the two fixed notification messages
654 // - ptc_compref: only for detailed PTC statistics
655 // - ptc_name: only for detailed PTC statistics
656 static void log_final_verdict(bool is_ptc, verdicttype ptc_verdict,
657 verdicttype local_verdict, verdicttype new_verdict,
658 const char *verdict_reason = NULL, int notification = -1,
659 int ptc_compref = UNBOUND_COMPREF, const char *ptc_name = NULL);
661 static void log_testcase_started (const qualified_name& testcase_name);
662 static void log_testcase_finished(const qualified_name& testcase_name,
665 static void log_controlpart_start_stop(const char *module_name, int finished);
666 static void log_controlpart_errors(unsigned int error_count);
668 static void log_verdict_statistics(size_t none_count, double none_percent,
669 size_t pass_count, double pass_percent,
670 size_t inconc_count, double inconc_percent,
671 size_t fail_count, double fail_percent,
672 size_t error_count, double error_percent);
674 static void log_defaultop_activate (const char *name, int id);
675 static void log_defaultop_deactivate(const char *name, int id);
676 static void log_defaultop_exit (const char *name, int id, int x);
678 /// EXECUTOR_RUNTIME, fixed strings only (no params)
679 static void log_executor_runtime(int reason);
680 /// EXECUTOR_RUNTIME, messages with parameters
681 static void log_HC_start(const char *host);
682 static void log_fd_limits(int fd_limit, long fd_set_size);
683 static void log_testcase_exec(const char *module, const char *tc);
684 static void log_module_init(const char *module, bool finish = false);
685 static void log_mtc_created(long pid);
687 /// EXECUTOR_CONFIGDATA
688 /// @param str module name, config file or NULL
689 static void log_configdata(int reason, const char *str = NULL);
691 static void log_executor_component(int reason);
693 static void log_executor_misc(int reason, const char *name, const char *address,
696 static void log_extcommand(extcommand_t action, const char *cmd);
697 //static void log_extcommand_success(const char *cmd);
699 static void log_matching_done(const char *type, int ptc,
700 const char *return_type, int reason);
702 static void log_matching_problem(int reason, int operation,
703 boolean check, boolean anyport, const char *port_name = NULL);
705 static void log_matching_success(int port_type, const char *port_name, int compref,
706 const CHARSTRING& info);
707 static void log_matching_failure(int port_type, const char *port_name, int compref,
708 int reason, const CHARSTRING& info);
710 static void log_matching_timeout(const char *timer_name);
712 static void log_portconnmap(int operation, int src_compref, const char *src_port,
713 int dst_compref, const char *dst_port);
715 static void log_par_ptc(int reason,
716 const char *module = NULL, const char *name = NULL, int compref = 0,
717 const char *compname = NULL, const char *tc_loc = NULL,
718 int alive_pid = 0, int status = 0);
720 static void log_port_queue(int operation, const char *port_name, int compref,
721 int id, const CHARSTRING& address, const CHARSTRING& param);
723 static void log_port_state(int operation, const char *port_name);
725 static void log_procport_send(const char *portname, int operation, int compref,
726 const CHARSTRING& system, const CHARSTRING& param);
727 static void log_procport_recv(const char *portname, int operation, int compref,
728 boolean check, const CHARSTRING& param, int id);
729 static void log_msgport_send(const char *portname, int compref,
730 const CHARSTRING& param);
731 static void log_msgport_recv(const char *portname, int operation, int compref,
732 const CHARSTRING& system, const CHARSTRING& param, int id);
734 static void log_dualport_map(boolean incoming, const char *target_type,
735 const CHARSTRING& value, int id);
736 static void log_dualport_discard(boolean incoming, const char *target_type,
737 const char *port_name, boolean unhaldled);
739 static void log_port_misc(int reason, const char *port_name,
740 int remote_component = NULL_COMPREF, const char *remote_port = NULL,
741 const char *ip_address = NULL, int tcp_port = -1, int new_size = 0);
743 static void log_random(int action, double v, unsigned long u);
745 static void clear_parameters();
746 /** @} TODO: More * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
749 /** @name #defines for backward-compatibility.
750 These #defines (TTCN_ERROR, TTCN_WARNING, ... TTCN_DEBUG)
751 are source-compatible (but \b not binary compatible) with the original #defines
753 @note The values are not bit masks. Expressions like
754 @code LOG_ALL | TTCN_DEBUG @endcode will not work correctly.
758 #define TTCN_ERROR TTCN_Logger::ERROR_UNQUALIFIED
759 #define TTCN_WARNING TTCN_Logger::WARNING_UNQUALIFIED
760 #define TTCN_PORTEVENT TTCN_Logger::PORTEVENT_UNQUALIFIED
761 #define TTCN_TIMEROP TTCN_Logger::TIMEROP_UNQUALIFIED
762 #define TTCN_VERDICTOP TTCN_Logger::VERDICTOP_UNQUALIFIED
763 #define TTCN_DEFAULTOP TTCN_Logger::DEFAULTOP_UNQUALIFIED
764 #define TTCN_ACTION TTCN_Logger::ACTION_UNQUALIFIED
765 #define TTCN_TESTCASE TTCN_Logger::TESTCASE_UNQUALIFIED
766 #define TTCN_FUNCTION TTCN_Logger::FUNCTION_UNQUALIFIED
767 #define TTCN_USER TTCN_Logger::USER_UNQUALIFIED
768 #define TTCN_STATISTICS TTCN_Logger::STATISTICS_UNQUALIFIED
769 #define TTCN_PARALLEL TTCN_Logger::PARALLEL_UNQUALIFIED
770 #define TTCN_EXECUTOR TTCN_Logger::EXECUTOR_UNQUALIFIED
771 #define TTCN_MATCHING TTCN_Logger::MATCHING_UNQUALIFIED
772 #define TTCN_DEBUG TTCN_Logger::DEBUG_UNQUALIFIED
773 #define LOG_NOTHING TTCN_Logger::NOTHING_TO_LOG
774 #define LOG_ALL TTCN_Logger::LOG_ALL_IMPORTANT
777 extern TTCN_Logger TTCN_logger;
779 class TTCN_Location {
781 enum entity_type_t { LOCATION_UNKNOWN, LOCATION_CONTROLPART,
782 LOCATION_TESTCASE, LOCATION_ALTSTEP, LOCATION_FUNCTION,
783 LOCATION_EXTERNALFUNCTION, LOCATION_TEMPLATE };
785 const char *file_name;
786 unsigned int line_number;
787 entity_type_t entity_type;
788 const char *entity_name;
789 TTCN_Location *inner_location, *outer_location;
790 static TTCN_Location *innermost_location, *outermost_location;
791 friend class LoggerPluginManager;
793 /** @brief Create a TTCN_Location object.
795 Objects of this class are created by code generated by the TTCN-3 compiler.
797 @param par_file_name source file of the call site
798 @param par_line_number line number of the call site
799 @param par_entity_type controlpart/testcase/altstep/function/...etc
800 @param par_entity_name entity name of the caller
802 @note The constructor copies the par_file_name and par_entity_name
803 pointers but not the strings. The caller must ensure that the strings
804 don't go out of scope before the TTCN_Location object.
806 TTCN_Location(const char *par_file_name, unsigned int par_line_number,
807 entity_type_t par_entity_type = LOCATION_UNKNOWN,
808 const char *par_entity_name = NULL);
809 virtual ~TTCN_Location();
811 virtual void update_lineno(unsigned int new_lineno);
813 /** @brief Write the current location information to a string.
815 * @param print_outers \c true to print all the callers
816 * (in the style of SourceInfo = Stack)
817 * @param print_innermost \c true to print the current (innermost) location
818 * @param print_entity_name \c true to print the type
819 * (control part/test case/altstep/function/template) and name
820 * of the current location.
821 * @note print_innermost is always TRUE (there is never a call with FALSE)
823 * @return an expstring_t. The caller is responsible for calling Free()
825 static char *print_location(boolean print_outers, boolean print_innermost,
826 boolean print_entity_name);
827 /** @brief Remove location information from a string.
829 * @param [in,out] par_str the string to modify.
830 * @pre par_str was allocated by Malloc, or is NULL.
831 * It may be an expstring_t.
833 * The function copies characters from \p par_str to a temporary string,
834 * except characters between parentheses. Then it calls
835 * \c Free(par_str) and replaces \p par_str with the temporary.
838 static void strip_entity_name(char*& par_str);
840 /** @brief Return the innermost location's line number
842 static unsigned int get_line_number();
844 char *append_contents(char *par_str, boolean print_entity_name) const;
847 class TTCN_Location_Statistics: public TTCN_Location
850 TTCN_Location_Statistics(const char *par_file_name, unsigned int par_line_number,
851 entity_type_t par_entity_type = LOCATION_UNKNOWN,
852 const char *par_entity_name = NULL);
853 ~TTCN_Location_Statistics();
854 void update_lineno(unsigned int new_lineno);
855 static void init_file_lines(const char *file_name, const int line_nos[], size_t line_nos_len);
856 static void init_file_functions(const char *file_name, const char *function_names[], size_t function_names_len);
859 /// Restores the original log format when running out of scope: use as local variable
860 class Logger_Format_Scope {
862 TTCN_Logger::data_log_format_t orig_log_format;
864 Logger_Format_Scope(TTCN_Logger::data_log_format_t p_log_format) { orig_log_format=TTCN_Logger::get_log_format(); TTCN_Logger::set_log_format(p_log_format); }
865 ~Logger_Format_Scope() { TTCN_Logger::set_log_format(orig_log_format); }