13 StMessMgr::StMessMgr() : std::ostringstream() {}
18 StMessMgr* StMessMgr::CurrentMessager() {
return gMessMgr;}
20 StMessMgr* StMessMgr::Instance() {
return (gMessMgr)?gMessMgr->Instantiate():0;}
22 StMessMgr* StMessMgr::Instance(
const char *loggerName)
23 {
return (gMessMgr)?gMessMgr->Instantiate(loggerName):0; }
33 StMessMgr* StMessMgr::Instantiate() {
return gMessMgr; }
35 StMessMgr* StMessMgr::Instantiate(
const char *){
return Instantiate();}
38 bool StMessMgr::isDebugEnabled()
const{
return true; }
40 bool StMessMgr::isWarnEnabled()
const{
return true; }
42 bool StMessMgr::isWarningEnabled()
const{
return isWarnEnabled(); }
44 bool StMessMgr::isErrorEnabled()
const{
return true; }
46 bool StMessMgr::isInfoEnabled()
const{
return true; }
48 bool StMessMgr::isFatalEnabled()
const{
return true; }
50 bool StMessMgr::isEnabledFor()
const{
return true; }
52 bool StMessMgr::isQAInfoEnabled()
const{
return true; }
54 bool StMessMgr::isUCMInfoEnabled()
const{
return true; }
59 static const char defaultMessType =
'I';
60 static char emptyString[] =
"";
61 static char oOpt[] =
"O";
62 static char otsOpt[] =
"OTS";
63 static char eOpt[] =
"E";
64 static char nullMess[] =
"Null message!!!";
66 static int sMessLength;
69 void type_of_call Message_(
const char* mess,
int* lines,
int*,
size_t len) {
70 static char space =
' ';
71 static const char* messReturnChar =
"\n";
72 size_t messSize = strlen(mess);
73 char* mess2=
const_cast<char*
> (mess);
76 char* mess1 =
const_cast<char*
> (mess);
77 mess2 =
new char[(messSize+1)]{};
79 for (
int i=(*lines); i>0; i--) {
81 while (mess1[--clen] == space) {}
82 strncat(mess2,mess1,(++clen));
84 strcat(mess2,messReturnChar);
85 mess1 = &(mess1[len]);
88 strcat(mess2,emptyString);
94 if ((len>1) && (messSize > len)) {
95 mess2 =
new char[(len+1)]{};
96 strncpy(mess2,mess,len);
100 gMessMgr->Message(mess2);
101 if (del_mess)
delete [] mess2;
104 void type_of_call Msg_Enable_(
const char* mess,
size_t len) {
105 size_t messlen = strlen(mess);
106 if ((len>1) && (messlen > len)) {
107 char* mess2 =
new char[(len+1)]{};
108 strncpy(mess2,mess,len);
109 gMessMgr->SwitchOn(mess2);
112 gMessMgr->SwitchOn(mess);
116 int type_of_call Msg_Enabled_(
const char* mess,
int*,
size_t len) {
117 size_t messlen = strlen(mess);
119 if ((len>1) && (messlen > len)) {
120 char* mess2 =
new char[(len+1)]{};
121 strncpy(mess2,mess,len);
122 if ((gMessMgr->GetLimit(mess2))==0) ret_val = 0;
125 if ((gMessMgr->GetLimit(mess))==0) ret_val = 0;
130 void type_of_call Msg_Disable_(
const char* mess,
size_t len) {
131 size_t messlen = strlen(mess);
132 if ((len>1) && (messlen > len)) {
133 char* mess2 =
new char[(len+1)]{};
134 strncpy(mess2,mess,len);
135 gMessMgr->SwitchOff(mess2);
138 gMessMgr->SwitchOff(mess);
142 void type_of_call MessageOut(
const char *msg ) {
143 gMessMgr->Message(msg);
146 void type_of_call StCaller(
const char* mess,
const char* typString,
147 const char* opt,
size_t len) {
152 gMessMgr->Message(nullMess,
"E",eOpt);
156 size_t messlen = strlen(mess);
157 if ((len>1) && (messlen > len)) messlen = len;
158 char* mess2 =
new char[(messlen+1)]{};
159 strncpy(mess2,mess,messlen);
161 gMessMgr->Message(mess2,typString,opt);
165 void type_of_call StCallerOpt(
const char* mess,
const char* typString,
166 const char* opt,
size_t len1,
size_t len2,
168 char* opt2=
const_cast<char*
> (opt);
173 }
else if (strlen(opt) > len2) {
174 opt2 =
new char[(len2+1)]{};
175 strncpy(opt2,opt,len2);
179 StCaller(mess,typString,opt2,len1);
180 if (del_opt)
delete [] opt2;
183 void type_of_call StMessage_(
const char* mess,
const char* type,
184 const char* opt,
size_t len1,
185 size_t len2,
size_t len3) {
186 char* type2=
const_cast<char*
> (type);
191 }
else if (strlen(type) > len2) {
192 type2 =
new char[(len2+1)]{};
193 strncpy(type2,type,len2);
197 StCallerOpt(mess,type2,opt,len1,len3,oOpt);
198 if (del_type)
delete [] type2;
201 void type_of_call StInfo_(
const char* mess,
size_t len) {
202 StCaller(mess,
"I",oOpt,len);
205 void type_of_call StWarning_(
const char* mess,
size_t len) {
206 StCaller(mess,
"W",eOpt,len);
209 void type_of_call StError_(
const char* mess,
size_t len) {
210 StCaller(mess,
"E",eOpt,len);
213 void type_of_call StDebug_(
const char* mess,
size_t len) {
214 StCaller(mess,
"D",oOpt,len);
217 void type_of_call QAInfo_(
const char* mess,
size_t len) {
218 StCaller(mess,
"Q",otsOpt,len);
221 void type_of_call UCMInfo_(
const char* mess,
size_t len) {
222 StCaller(mess,
"U",otsOpt,len);
225 void type_of_call StInfoOpt_(
const char* mess,
const char* opt,
226 size_t len1,
size_t len2) {
227 StCallerOpt(mess,
"I",opt,len1,len2,oOpt);
230 void type_of_call StWarningOpt_(
const char* mess,
const char* opt,
231 size_t len1,
size_t len2) {
232 StCallerOpt(mess,
"W",opt,len1,len2,eOpt);
235 void type_of_call StErrorOpt_(
const char* mess,
const char* opt,
236 size_t len1,
size_t len2) {
237 StCallerOpt(mess,
"E",opt,len1,len2,eOpt);
240 void type_of_call StDebugOpt_(
const char* mess,
const char* opt,
241 size_t len1,
size_t len2) {
242 StCallerOpt(mess,
"D",opt,len1,len2,oOpt);
245 void type_of_call QAInfoOpt_(
const char* mess,
const char* opt,
246 size_t len1,
size_t len2) {
247 StCallerOpt(mess,
"Q",opt,len1,len2,otsOpt);
250 void type_of_call UCMInfoOpt_(
const char* mess,
const char* opt,
251 size_t len1,
size_t len2) {
252 StCallerOpt(mess,
"U",opt,len1,len2,otsOpt);
255 void type_of_call StMessAddType_(
const char* type,
const char* text,
256 size_t len1,
size_t len2) {
257 if (strlen(type) > len1) (
const_cast<char*
> (type))[len1] = 0;
258 if (strlen(text) > len2) (const_cast<char*> (text))[len2] = 0;
259 gMessMgr->AddType(type,text);