2012-07-24 16:43:34 +00:00
|
|
|
/*******************************************************************************
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
This file is part of LibMaxsi.
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
LibMaxsi is free software: you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the Free
|
|
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
any later version.
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
|
2011-08-05 12:25:00 +00:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
2012-07-24 16:43:34 +00:00
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
2011-08-05 12:25:00 +00:00
|
|
|
details.
|
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with LibMaxsi. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-05 12:25:00 +00:00
|
|
|
|
|
|
|
log.h
|
|
|
|
A system for logging various messages to the kernel log.
|
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
*******************************************************************************/
|
2011-08-05 12:25:00 +00:00
|
|
|
|
|
|
|
#ifndef SORTIX_LOG_H
|
|
|
|
#define SORTIX_LOG_H
|
|
|
|
|
|
|
|
#include <libmaxsi/string.h>
|
|
|
|
#include <libmaxsi/format.h>
|
|
|
|
|
|
|
|
namespace Sortix
|
|
|
|
{
|
|
|
|
namespace Log
|
|
|
|
{
|
|
|
|
extern Maxsi::Format::Callback deviceCallback;
|
2012-07-24 16:43:34 +00:00
|
|
|
extern size_t (*deviceWidth)(void*);
|
|
|
|
extern size_t (*deviceHeight)(void*);
|
2011-08-05 12:25:00 +00:00
|
|
|
extern void* devicePointer;
|
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
void Init(Maxsi::Format::Callback callback,
|
|
|
|
size_t (*widthfunc)(void*),
|
|
|
|
size_t (*heightfunc)(void*),
|
|
|
|
void* user);
|
2012-03-21 23:52:29 +00:00
|
|
|
|
2011-08-05 12:25:00 +00:00
|
|
|
inline void Flush()
|
|
|
|
{
|
|
|
|
if ( deviceCallback ) { deviceCallback(devicePointer, NULL, 0); }
|
|
|
|
}
|
|
|
|
|
2012-07-24 16:43:34 +00:00
|
|
|
inline size_t Width()
|
|
|
|
{
|
|
|
|
return deviceWidth(devicePointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t Height()
|
|
|
|
{
|
|
|
|
return deviceHeight(devicePointer);
|
|
|
|
}
|
|
|
|
|
2011-08-05 12:25:00 +00:00
|
|
|
inline size_t Print(const char* str)
|
|
|
|
{
|
2012-01-22 01:12:52 +00:00
|
|
|
using namespace Maxsi;
|
|
|
|
if ( !deviceCallback ) { return 0; }
|
|
|
|
return deviceCallback(devicePointer, str, String::Length(str));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t PrintData(const void* ptr, size_t size)
|
|
|
|
{
|
|
|
|
if ( !deviceCallback ) { return 0; }
|
2012-03-21 23:52:29 +00:00
|
|
|
return deviceCallback(devicePointer, (const char*) ptr, size);
|
2011-08-05 12:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t PrintF(const char* format, ...)
|
|
|
|
{
|
2012-01-22 01:12:52 +00:00
|
|
|
using namespace Maxsi;
|
2011-08-05 12:25:00 +00:00
|
|
|
va_list list;
|
|
|
|
va_start(list, format);
|
2012-01-22 01:12:52 +00:00
|
|
|
size_t result = Format::Virtual(deviceCallback, devicePointer, format, list);
|
2011-08-05 12:25:00 +00:00
|
|
|
va_end(list);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t PrintFV(const char* format, va_list list)
|
|
|
|
{
|
2012-01-22 01:12:52 +00:00
|
|
|
using namespace Maxsi;
|
|
|
|
return Format::Virtual(deviceCallback, devicePointer, format, list);
|
2011-08-05 12:25:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|