Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F527292
Logger.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
Logger.cpp
View Options
#include
"Logger.h"
#include
<shlwapi.h>
#include
<atlconv.h>
#include
<fstream>
WCHAR
Logger
::
logbuf
[
300
];
char
Logger
::
logbufChar
[
300
];
void
Logger
::
log
(
const
WCHAR
*
format
,
...)
{
if
(
!
format
)
{
return
;
}
//ZeroMemory(logbuf, sizeof(logbuf));
va_list
va_alist
;
va_start
(
va_alist
,
format
);
_vsnwprintf_s
(
logbuf
,
_countof
(
logbuf
),
_countof
(
logbuf
)
-
1
,
format
,
va_alist
);
va_end
(
va_alist
);
write
(
logbuf
);
}
void
Logger
::
log
(
const
char
*
format
,
...)
{
if
(
!
format
)
{
return
;
}
//ZeroMemory(logbufChar, sizeof(logbufChar));
va_list
va_alist
;
va_start
(
va_alist
,
format
);
_vsnprintf_s
(
logbufChar
,
_countof
(
logbufChar
),
_countof
(
logbufChar
)
-
1
,
format
,
va_alist
);
va_end
(
va_alist
);
write
(
logbufChar
);
}
void
Logger
::
write
(
const
CHAR
*
str
)
{
size_t
len
=
strlen
(
str
)
+
1
;
WCHAR
*
buf
=
new
WCHAR
[
len
];
size_t
convertedChars
=
0
;
mbstowcs_s
(
&
convertedChars
,
buf
,
len
,
str
,
_TRUNCATE
);
write
(
buf
);
delete
[]
buf
;
}
FileLog
::
FileLog
(
const
WCHAR
*
fileName
)
{
GetModuleFileName
(
0
,
this
->
filePath
,
_countof
(
this
->
filePath
));
PathRemoveFileSpec
(
this
->
filePath
);
PathAppend
(
this
->
filePath
,
fileName
);
}
void
FileLog
::
write
(
const
CHAR
*
str
)
{
/*
std::wofstream file(filePath, std::wofstream::app);
if(!file.fail())
{
file << str << std::endl;
}
*/
FILE
*
pFile
;
if
(
_wfopen_s
(
&
pFile
,
filePath
,
L
"a"
)
==
0
)
{
fputs
(
str
,
pFile
);
fputs
(
"
\r\n
"
,
pFile
);
fclose
(
pFile
);
}
}
void
FileLog
::
write
(
const
WCHAR
*
str
)
{
/*
std::wofstream file(filePath, std::wofstream::app);
if(!file.fail())
{
file << str << std::endl;
}
*/
FILE
*
pFile
;
if
(
_wfopen_s
(
&
pFile
,
filePath
,
L
"a"
)
==
0
)
{
fputws
(
str
,
pFile
);
fputws
(
L
"
\r\n
"
,
pFile
);
fclose
(
pFile
);
}
}
void
ListboxLog
::
setWindow
(
HWND
window
)
{
this
->
window
=
window
;
}
void
ListboxLog
::
write
(
const
WCHAR
*
str
)
{
LRESULT
index
=
SendMessageW
(
window
,
LB_ADDSTRING
,
0
,
reinterpret_cast
<
LPARAM
>
(
str
));
SendMessage
(
window
,
LB_SETCURSEL
,
index
,
0
);
UpdateWindow
(
window
);
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Wed, Jan 7, 1:51 PM (8 h, 5 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1d/49/c6a098621f2537d8517526fc037e
Attached To
rSCY Scylla
Event Timeline
Log In to Comment