-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogToFile.cpp
39 lines (32 loc) · 1.41 KB
/
LogToFile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//---------------------------------------------------------------------------
#pragma hdrstop
#include <algorithm>
#include "LogToFile.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
namespace SvcApp {
//---------------------------------------------------------------------------
namespace Log {
//---------------------------------------------------------------------------
String PadStringToCenter( String Txt, int MaxLen, TCHAR FillChar )
{
const int Diff = std::max( 0, MaxLen - Txt.Length() );
const int HalfDiff = Diff / 2;
const int LeftPadLen = Diff - HalfDiff;
const int RightPadLen = HalfDiff;
const int StrLen = MaxLen - Diff;
return Format(
_T( "%*.*s%-*.*s%*.*s" ), // Do not localize
ARRAYOFCONST( (
LeftPadLen, LeftPadLen, StringOfChar( FillChar, LeftPadLen ),
StrLen, StrLen, Txt,
RightPadLen, RightPadLen, StringOfChar( FillChar, RightPadLen )
) )
);
}
//---------------------------------------------------------------------------
}; // End of namespace Log
//---------------------------------------------------------------------------
}; // End of namespace SvcApp
//---------------------------------------------------------------------------