1 //-----------------------------------------------------------------------------
2 //
3 //	LogImpl.h
4 //
5 //	WinRT implementation of message and error logging
6 //
7 //	Copyright (c) 2015 Microsoft Corporation
8 //	All rights reserved.
9 //
10 //	SOFTWARE NOTICE AND LICENSE
11 //
12 //	This file is part of OpenZWave.
13 //
14 //	OpenZWave is free software: you can redistribute it and/or modify
15 //	it under the terms of the GNU Lesser General Public License as published
16 //	by the Free Software Foundation, either version 3 of the License,
17 //	or (at your option) any later version.
18 //
19 //	OpenZWave is distributed in the hope that it will be useful,
20 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
21 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 //	GNU Lesser General Public License for more details.
23 //
24 //	You should have received a copy of the GNU Lesser General Public License
25 //	along with OpenZWave.  If not, see <http://www.gnu.org/licenses/>.
26 //
27 //-----------------------------------------------------------------------------
28 #ifndef _LogImpl_H
29 #define _LogImpl_H
30 
31 #include "Defs.h"
32 #include <string>
33 #include "platform/Log.h"
34 #include "Windows.h"
35 
36 namespace OpenZWave
37 {
38 	/** \brief Windows-specific implementation of the Log class.
39 	 */
40 	class LogImpl : public i_LogImpl
41 	{
42 	private:
43 		friend class Log;
44 
45 		LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger );
46 		~LogImpl();
47 
48 		void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args );
49 		void Queue( char const* _buffer );
50 		void QueueDump();
51 		void QueueClear();
52 		void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger );
53 		void SetLogFileName( const string &_filename );
54 
55 		string GetTimeStampString();
56 		string GetNodeString( uint8 const _nodeId );
57 		string GetThreadId();
58 		string GetLogLevelString(LogLevel _level);
59 
60 		string m_filename;						/**< filename specified by user (default is ozw_log.txt) */
61 		bool m_bConsoleOutput;					/**< if true, send log output to console as well as to the file */
62 		bool m_bAppendLog;						/**< if true, the log file should be appended to any with the same name */
63 		list<string> m_logQueue;				/**< list of queued log messages */
64 		LogLevel m_saveLevel;
65 		LogLevel m_queueLevel;
66 		LogLevel m_dumpTrigger;
67 	};
68 
69 } // namespace OpenZWave
70 
71 #endif //_LogImpl_H
72 
73