source: trunk/src/log.cpp @ 939

Last change on this file since 939 was 939, checked in by sam, 12 years ago

build: stop defining ANDROID_NDK and check for ANDROID instead.

According to David Turner, “it should be the only thing that NDK users
should be testing again.”

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cmath>
16#include <cstdio>
17
18#if defined __ANDROID__
19#   include <android/log.h>
20#else
21#   include <cstdarg>
22#endif
23
24#include "core.h"
25
26namespace lol
27{
28
29/*
30 * Public Log class
31 */
32
33void Log::Debug(char const *fmt, ...)
34{
35    va_list ap;
36    va_start(ap, fmt);
37#if defined __ANDROID__
38    __android_log_vprint(ANDROID_LOG_DEBUG, "LOL", fmt, ap);
39#else
40    fprintf(stderr, "DEBUG: ");
41    vfprintf(stderr, fmt, ap);
42#endif
43    va_end(ap);
44}
45
46void Log::Info(char const *fmt, ...)
47{
48    va_list ap;
49    va_start(ap, fmt);
50#if defined __ANDROID__
51    __android_log_vprint(ANDROID_LOG_INFO, "LOL", fmt, ap);
52#else
53    fprintf(stderr, "INFO: ");
54    vfprintf(stderr, fmt, ap);
55#endif
56    va_end(ap);
57}
58
59void Log::Warn(char const *fmt, ...)
60{
61    va_list ap;
62    va_start(ap, fmt);
63#if defined __ANDROID__
64    __android_log_vprint(ANDROID_LOG_WARN, "LOL", fmt, ap);
65#else
66    fprintf(stderr, "WARN: ");
67    vfprintf(stderr, fmt, ap);
68#endif
69    va_end(ap);
70}
71
72void Log::Error(char const *fmt, ...)
73{
74    va_list ap;
75    va_start(ap, fmt);
76#if defined __ANDROID__
77    __android_log_vprint(ANDROID_LOG_ERROR, "LOL", fmt, ap);
78#else
79    fprintf(stderr, "ERROR: ");
80    vfprintf(stderr, fmt, ap);
81#endif
82    va_end(ap);
83}
84
85} /* namespace lol */
86
Note: See TracBrowser for help on using the repository browser.