Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

logger.cpp

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #include "precomp.h"
00030 #include "logger.h"
00031 
00033 // CL_Logger Construction:
00034 
00035 CL_Logger::CL_Logger()
00036 {
00037 }
00038         
00039 CL_Logger::~CL_Logger()
00040 {
00041         disable();
00042 }
00043 
00045 // CL_Logger Attributes:
00046 
00047 CL_Logger *CL_Logger::instance = 0;
00048 
00049 CL_Mutex CL_Logger::mutex;
00050 
00052 // CL_Logger Operations:
00053 
00054 void CL_Logger::enable()
00055 {
00056         CL_MutexSection mutex_lock(&CL_Logger::mutex);
00057         instance = this;
00058 }
00059         
00060 void CL_Logger::disable()
00061 {
00062         CL_MutexSection mutex_lock(&CL_Logger::mutex);
00063         instance = 0;
00064 }
00065 
00066 void cl_log_event(const CL_StringA &type, const CL_StringW &text)
00067 {
00068         CL_MutexSection mutex_lock(&CL_Logger::mutex);
00069         if (CL_Logger::instance == 0)
00070                 return;
00071         CL_Logger::instance->log(type, CL_StringHelp::ucs2_to_text(text));
00072 }
00073 
00074 void cl_log_event(const CL_StringA &type, const CL_StringA &text)
00075 {
00076         CL_MutexSection mutex_lock(&CL_Logger::mutex);
00077         if (CL_Logger::instance == 0)
00078                 return;
00079         CL_Logger::instance->log(type, CL_StringHelp::local8_to_text(text));
00080 }
00081 
00083 // CL_Logger Implementation:

Generated on Sat Feb 19 22:51:16 2005 for npcore by  doxygen 1.4.1