Skip to content

Commit

Permalink
Merge pull request #159 from jcoby/enable-console-logging
Browse files Browse the repository at this point in the history
Enable console logging if MONO or LOGGER is defined
  • Loading branch information
Lgt2x authored Apr 23, 2024
2 parents 86a6c13 + 96ce6d2 commit 959a453
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if(NOT MSVC) # GCC/clang or compatible, hopefully
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with ninja)." OFF)
endif()

option(LOGGER "Enable logging to the terminal" OFF)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -97,6 +99,11 @@ if(WIN32)
endif()
endif()

if(LOGGER)
message("Enabling Logging")
add_definitions(-DLOGGER)
endif()

include_directories("lib" "Descent3" ${PLATFORM_INCLUDES})

# file(GLOB_RECURSE INCS "*.h")
Expand Down
6 changes: 3 additions & 3 deletions Descent3/init.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Descent 3
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -1153,7 +1153,7 @@ void PreInitD3Systems() {

debugging = (FindArg("-debug") != 0);

#ifdef MONO
#ifdef LOGGER
console_output = true;
#endif
#ifndef MACINTOSH
Expand Down Expand Up @@ -2151,7 +2151,7 @@ void InitD3Systems1(bool editor) {
#if 0
//CD Check goes here
//#if ( defined(RELEASE) && (!defined(DEMO)) && (!defined(GAMEGAUGE)) )
if( (!FindArg("-dedicated")) )
if( (!FindArg("-dedicated")) )
PreGameCdCheck();
#endif

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ Build steps below assume you have already cloned the repository and entered it l
Requires Visual Studio C++ Tools (cmake and nmake)
```sh
cmake --preset win
cmake --build --preset win --config [Debug/Release]
cmake --build --preset win --config [Debug/Release] -D LOGGER=[ON|OFF]
```

#### Building - MacOS
```sh
brew bundle install
cmake --preset mac
cmake --build --preset mac --config [Debug/Release]
cmake --build --preset mac --config [Debug/Release] -D LOGGER=[ON|OFF]
```

#### Building - Linux
Expand All @@ -44,7 +44,7 @@ sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev libxext6:i386
cmake --preset linux
cmake --build --preset linux --config [Debug/Release]
cmake --build --preset linux --config [Debug/Release] -D LOGGER=[ON|OFF]
```

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions lib/debug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Descent 3
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -166,7 +166,7 @@ bool Debug_ConsoleInit();
void Debug_ConsoleOpen(int n, int row, int col, int width, int height, char *title);
void Debug_ConsoleClose(int n);
void Debug_ConsolePrintf(int n, char *format, ...);
void Debug_ConsolePrintf(int n, int row, int col, char *format, ...);
void Debug_ConsolePrintfAt(int n, int row, int col, char *format, ...);
void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window);
// DEBUGGING MACROS
// Break into the debugger, if this feature was enabled in Debug_init()
Expand Down
6 changes: 3 additions & 3 deletions lib/mono.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Descent 3
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -66,12 +66,12 @@
#include "debug.h"
void nw_InitTCPLogging(char *ip, unsigned short port);
void nw_TCPPrintf(int n, char *format, ...);
#if (!defined(RELEASE)) && defined(MONO)
#if (!defined(RELEASE)) && defined(LOGGER)
extern bool Debug_print_block;
// Prints a formatted string to the debug window
#define mprintf(args) Debug_ConsolePrintf args
// Prints a formatted string on window n at row, col.
#define mprintf_at(args) Debug_ConsolePrintf args
#define mprintf_at(args) Debug_ConsolePrintfAt args
#define DebugBlockPrint(args) \
do { \
if (Debug_print_block) \
Expand Down
4 changes: 2 additions & 2 deletions linux/lnxmono.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Descent 3
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -554,7 +554,7 @@ void Debug_ConsolePrintf(int n, char *format, ...) {
}
}

void Debug_ConsolePrintf(int n, int row, int col, char *format, ...) {
void Debug_ConsolePrintfAt(int n, int row, int col, char *format, ...) {
if (!Mono_initialized)
return;

Expand Down

0 comments on commit 959a453

Please sign in to comment.