mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-21 12:40:34 +00:00
Add she::Logger to log errors in Mac OS X console
This commit is contained in:
parent
be0b7de49e
commit
4921eeca9c
@ -5,8 +5,12 @@ set(SHE_SOURCES
|
||||
alleg4/fontbmp.cpp
|
||||
alleg4/she_alleg4.cpp)
|
||||
|
||||
if(APPLE AND NOT USE_SHARED_ALLEGRO4)
|
||||
list(APPEND SHE_SOURCES alleg4/app.mm)
|
||||
if(APPLE)
|
||||
if(NOT USE_SHARED_ALLEGRO4)
|
||||
list(APPEND SHE_SOURCES alleg4/app.mm)
|
||||
endif()
|
||||
|
||||
list(APPEND SHE_SOURCES osx/logger.mm)
|
||||
endif()
|
||||
|
||||
add_library(she ${SHE_SOURCES})
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/string.h"
|
||||
#include "she/alleg4/alleg4_font.h"
|
||||
#include "she/alleg4/alleg4_surface.h"
|
||||
#include "she/logger.h"
|
||||
|
||||
#include <allegro.h>
|
||||
#include <allegro/internal/aintern.h>
|
||||
@ -22,6 +23,7 @@
|
||||
#include <winalleg.h>
|
||||
|
||||
#include <windowsx.h>
|
||||
|
||||
#include <commctrl.h>
|
||||
|
||||
#if defined STRICT || defined __GNUC__
|
||||
@ -78,6 +80,10 @@ static void resize_callback(RESIZE_DISPLAY_EVENT* ev)
|
||||
|
||||
namespace she {
|
||||
|
||||
#ifdef __APPLE__
|
||||
Logger* getOsxLogger();
|
||||
#endif
|
||||
|
||||
class Alleg4EventQueue : public EventQueue {
|
||||
public:
|
||||
Alleg4EventQueue() {
|
||||
@ -681,6 +687,14 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
Logger* logger() override {
|
||||
#ifdef __APPLE__
|
||||
return getOsxLogger();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Display* defaultDisplay() override {
|
||||
return unique_display;
|
||||
}
|
||||
@ -740,6 +754,9 @@ System* instance()
|
||||
|
||||
void error_message(const char* msg)
|
||||
{
|
||||
if (g_instance && g_instance->logger())
|
||||
g_instance->logger()->logError(msg);
|
||||
|
||||
#ifdef WIN32
|
||||
std::wstring wmsg = base::from_utf8(msg);
|
||||
std::wstring title = base::from_utf8(PACKAGE);
|
||||
|
21
src/she/logger.h
Normal file
21
src/she/logger.h
Normal file
@ -0,0 +1,21 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2014 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef SHE_LOGGER_H_INCLUDED
|
||||
#define SHE_LOGGER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace she {
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
virtual ~Logger() { }
|
||||
virtual void logError(const char* error) = 0;
|
||||
};
|
||||
|
||||
} // namespace she
|
||||
|
||||
#endif
|
25
src/she/osx/logger.mm
Normal file
25
src/she/osx/logger.mm
Normal file
@ -0,0 +1,25 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2014 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include "she/logger.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
class OSXLogger : public Logger {
|
||||
public:
|
||||
void logError(const char* error) override {
|
||||
NSLog([NSString stringWithUTF8String:error]);
|
||||
}
|
||||
};
|
||||
|
||||
Logger* getOsxLogger() {
|
||||
return new OSXLogger;
|
||||
}
|
||||
|
||||
} // namespace she
|
@ -17,6 +17,7 @@ namespace she {
|
||||
class Display;
|
||||
class EventLoop;
|
||||
class Font;
|
||||
class Logger;
|
||||
class Surface;
|
||||
|
||||
class DisplayCreationException : std::runtime_error {
|
||||
@ -30,6 +31,7 @@ namespace she {
|
||||
virtual ~System() { }
|
||||
virtual void dispose() = 0;
|
||||
virtual Capabilities capabilities() const = 0;
|
||||
virtual Logger* logger() = 0;
|
||||
virtual Display* defaultDisplay() = 0;
|
||||
virtual Font* defaultFont() = 0;
|
||||
virtual Display* createDisplay(int width, int height, int scale) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user