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
13 ******************************************************************************/
15 #include "TitanLoggerControl.hh"
17 #include "LoggingBits.hh"
18 #include "Component.hh"
20 // TODO: We should ask somebody instead...
21 const char LegacyLoggerName
[] = "LegacyLogger";
23 void validate_plugin_name(CHARSTRING
const& plugin
)
25 if (strcmp(LegacyLoggerName
, (const char *)plugin
))
26 TTCN_error("Only `%s' can be configured dynamically.", LegacyLoggerName
);
29 namespace TitanLoggerControl
{
31 void set__log__file(CHARSTRING
const& plugin
, CHARSTRING
const& filename
)
33 validate_plugin_name(plugin
);
35 TTCN_Logger::set_file_name(filename
, false);
36 TTCN_Logger::open_file();
39 void set__log__entity__name(CHARSTRING
const& plugin
, BOOLEAN
const& log_it
)
41 validate_plugin_name(plugin
);
43 TTCN_Logger::set_log_entity_name(log_it
);
46 BOOLEAN
get__log__entity__name(CHARSTRING
const& plugin
)
48 validate_plugin_name(plugin
);
50 return BOOLEAN(TTCN_Logger::get_log_entity_name());
53 void set__matching__verbosity(CHARSTRING
const& plugin
, verbosity
const& v
)
55 validate_plugin_name(plugin
);
57 TTCN_Logger::set_matching_verbosity(
58 static_cast<TTCN_Logger::matching_verbosity_t
>(v
.as_int()));
61 verbosity
get__matching__verbosity(CHARSTRING
const& plugin
)
63 validate_plugin_name(plugin
);
65 verbosity
retval(TTCN_Logger::get_matching_verbosity());
69 Severities
get__file__mask(CHARSTRING
const& plugin
)
71 validate_plugin_name(plugin
);
73 Severities
retval(NULL_VALUE
); // Empty but initialized.
74 Logging_Bits
const& lb
= TTCN_Logger::get_file_mask();
75 for (int i
= 1, s
= 0; i
< TTCN_Logger::NUMBER_OF_LOGSEVERITIES
; ++i
) {
77 retval
[s
++] = Severity(i
);
78 // operator[] creates a new element and we assign a temporary to it
85 Severities
get__console__mask(CHARSTRING
const& plugin
)
87 validate_plugin_name(plugin
);
89 Severities
retval(NULL_VALUE
); // Empty but initialized.
90 Logging_Bits
const& lb
= TTCN_Logger::get_console_mask();
91 for (int i
= 1, s
= 0; i
< TTCN_Logger::NUMBER_OF_LOGSEVERITIES
; ++i
) {
93 retval
[s
++] = Severity(i
);
94 // operator[] creates a new element and we assign a temporary to it
101 void set__console__mask(CHARSTRING
const& plugin
, Severities
const& mask
)
103 validate_plugin_name(plugin
);
105 Logging_Bits
lb(Logging_Bits::log_nothing
);
106 for (int B
= mask
.size_of() - 1; B
>= 0; B
--) {
107 lb
.add_sev(static_cast<TTCN_Logger::Severity
>((int)mask
[B
]));
109 component_id_t cmpt_id
= { COMPONENT_ID_COMPREF
, { self
} };
110 TTCN_Logger::set_console_mask(cmpt_id
, lb
);
113 void set__file__mask(CHARSTRING
const& plugin
, Severities
const& mask
)
115 validate_plugin_name(plugin
);
117 Logging_Bits
lb(Logging_Bits::log_nothing
);
118 for (int B
= mask
.size_of() - 1; B
>= 0; B
--) {
119 lb
.add_sev(static_cast<TTCN_Logger::Severity
>((int)mask
[B
]));
121 component_id_t cmpt_id
= { COMPONENT_ID_COMPREF
, { self
} };
122 TTCN_Logger::set_file_mask(cmpt_id
, lb
);
125 void add__to__console__mask(CHARSTRING
const& plugin
, Severities
const& mask
)
127 validate_plugin_name(plugin
);
129 Logging_Bits
lb(TTCN_Logger::get_console_mask());
130 for (int B
= mask
.size_of() - 1; B
>= 0; B
--) {
131 lb
.add_sev(static_cast<TTCN_Logger::Severity
>((int)mask
[B
]));
133 component_id_t cmpt_id
= { COMPONENT_ID_COMPREF
, { self
} };
134 TTCN_Logger::set_console_mask(cmpt_id
, lb
);
137 void add__to__file__mask(CHARSTRING
const& plugin
, Severities
const& mask
)
139 validate_plugin_name(plugin
);
141 Logging_Bits
lb(TTCN_Logger::get_file_mask());
142 for (int B
= mask
.size_of() - 1; B
>= 0; B
--) {
143 lb
.add_sev(static_cast<TTCN_Logger::Severity
>((int)mask
[B
]));
145 component_id_t cmpt_id
= { COMPONENT_ID_COMPREF
, { self
} };
146 TTCN_Logger::set_file_mask(cmpt_id
, lb
);
149 void remove__from__console__mask(CHARSTRING
const& plugin
, Severities
const& mask
)
151 validate_plugin_name(plugin
);
153 Logging_Bits
lb(TTCN_Logger::get_console_mask());
154 for (int B
= mask
.size_of() - 1; B
>= 0; B
--) {
155 TTCN_Logger::Severity sev
= static_cast<TTCN_Logger::Severity
>((int)mask
[B
]);
156 if (sev
> 0 && sev
< TTCN_Logger::NUMBER_OF_LOGSEVERITIES
) {
157 lb
.bits
[sev
] = false;
160 component_id_t cmpt_id
= { COMPONENT_ID_COMPREF
, { self
} };
161 TTCN_Logger::set_console_mask(cmpt_id
, lb
);
164 void remove__from__file__mask(CHARSTRING
const& plugin
, Severities
const& mask
)
166 validate_plugin_name(plugin
);
168 Logging_Bits
lb(TTCN_Logger::get_file_mask());
169 for (int B
= mask
.size_of() - 1; B
>= 0; B
--) {
170 TTCN_Logger::Severity sev
= static_cast<TTCN_Logger::Severity
>((int)mask
[B
]);
171 if (sev
> 0 && sev
< TTCN_Logger::NUMBER_OF_LOGSEVERITIES
) {
172 lb
.bits
[sev
] = false;
175 component_id_t cmpt_id
= { COMPONENT_ID_COMPREF
, { self
} };
176 TTCN_Logger::set_file_mask(cmpt_id
, lb
);
This page took 0.045554 seconds and 5 git commands to generate.