Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/Tools/3dsmaxExport/LEXIExporter/SharedUtilities/Sources/FileLogger.cpp @ 11

Last change on this file since 11 was 6, checked in by anonymous, 18 years ago

=…

File size: 1.8 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of LEXIExporter
4
5Copyright 2006 NDS Limited
6
7Author(s):
8Bo Krohn
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26#include "stdafx.h"
27
28CFileLogger::CFileLogger(const char *pszFile, bool bLogTimes, ELogLevel eMinLevel)
29{
30        m_bLogTimes=bLogTimes;
31        m_eMinLevel=eMinLevel;
32        m_hFileHandle=CreateFile(pszFile, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, NULL); 
33}
34CFileLogger::~CFileLogger(void)
35{
36        CloseHandle(m_hFileHandle);
37//      FreeConsole();
38}
39
40// Called from the logsystem
41void CFileLogger::ReceiveLogMessage(SYSTEMTIME &LogTime, const char *pszTimeStr, int iMessageLevel, const char *pszMessage)
42{
43        // Do we want to write the message?
44        if(iMessageLevel<m_eMinLevel || m_hFileHandle==INVALID_HANDLE_VALUE) return;
45
46        // Write to console
47        DWORD dwWritten;
48        if(m_bLogTimes)
49                WriteFile(m_hFileHandle, pszTimeStr, (DWORD)strlen(pszTimeStr), &dwWritten, NULL);
50        WriteFile(m_hFileHandle, pszMessage, (DWORD)strlen(pszMessage), &dwWritten, NULL);
51}
Note: See TracBrowser for help on using the repository browser.