source: cpp/common/loggers/loggertostdout.cpp @ 714

Last change on this file since 714 was 522, checked in by Maciej Komosinski, 9 years ago

Code formatting

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#include "loggertostdout.h"
6#include <common/console.h>
7#ifdef SHP
8#include <FBaseSys.h> //AppLog
9#else
10#include <stdio.h>
11#endif
12
13static const char* default_log_level_ansicolor[] =
14{ "[\033[2mDEBUG\033[0m] \033[2m", "", "[\033[33mWARN\033[0m] \033[1m", "[\033[1;31mERROR\033[0m] \033[1m", "[\033[1;31mCRITICAL\033[0m] \033[1m" };
15
16const char** LoggerToStdout::default_log_level[] =
17{ LOG_LEVEL, default_log_level_ansicolor };
18
19const char* LoggerToStdout::default_log_format[] = //note trailing %s (so it's easy to append "\n" later)
20{ LOG_FORMAT "%s", "%s%s.%s: %s\033[0m%s" };
21
22LoggerToStdout::LoggerToStdout(int opts, VirtFILE *_file)
23        :LoggerBase(opts), file(_file)
24{
25        log_format = default_log_format[console_color_mode];
26        log_level = default_log_level[console_color_mode];
27}
28
29void LoggerToStdout::handleSingleLine(const char *obj, const char *method, int level, const char *msg)
30{
31        if (level < -1) level = -1; else if (level>3) level = 3;
32#ifdef SHP
33        AppLog(LOG_FORMAT "\n",LOG_LEVEL[level+1],obj,method,msg);
34#else
35        if (file)
36                file->printf(LOG_FORMAT "\n", LOG_LEVEL[level + 1], obj, method, msg);
37        else
38                printf(log_format, log_level[level + 1], obj, method, msg, "\n");
39#endif
40}
Note: See TracBrowser for help on using the repository browser.