Skip to content

Commit

Permalink
Merge pull request #20 from OutpostUniverse/UseStringViewInErrorLog
Browse files Browse the repository at this point in the history
Use string view in error log
  • Loading branch information
Brett208 authored Feb 29, 2020
2 parents dfbde0e + 6700ae5 commit 525305a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
language: cpp
sudo: false
os:
- linux
- osx
compiler:
- gcc
Expand Down
10 changes: 5 additions & 5 deletions ErrorLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
std::ostream& logFile = std::cerr;


void LogMessage(const char* message)
void LogMessage(std::string_view message)
{
logFile << message << std::endl;
}

void LogString(const char* message, const char* string)
void LogString(std::string_view message, std::string_view string)
{
logFile << message << string << std::endl;
}

void LogValue(const char* message, int value)
void LogValue(std::string_view message, int value)
{
logFile << message << std::dec << value << std::endl;
}

void LogValueHex(const char* message, int value)
void LogValueHex(std::string_view message, int value)
{
logFile << message << std::hex << value << std::endl;
}

void LogEndpoint(const char* message, unsigned long ipAddr, unsigned short port)
void LogEndpoint(std::string_view message, unsigned long ipAddr, unsigned short port)
{
union
{
Expand Down
11 changes: 6 additions & 5 deletions ErrorLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

#include "GameServer.h"
#include <iostream>
#include <string_view>


void LogMessage(const char* message);
void LogString(const char* message, const char* string);
void LogValue(const char* message, int value);
void LogValueHex(const char* message, int value);
void LogEndpoint(const char* message, unsigned long ipAddr, unsigned short port);
void LogMessage(std::string_view message);
void LogString(std::string_view message, std::string_view string);
void LogValue(std::string_view message, int value);
void LogValueHex(std::string_view message, int value);
void LogEndpoint(std::string_view message, unsigned long ipAddr, unsigned short port);

void LogCounters(GameServerCounters& counters);
2 changes: 2 additions & 0 deletions OPUNetGameServer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<ObjectFileName>.\Debug\</ObjectFileName>
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Midl>
<TypeLibraryName>.\Debug\OPUNetGameServer.tlb</TypeLibraryName>
Expand Down Expand Up @@ -94,6 +95,7 @@
<PrecompiledHeaderOutputFile>.\Release\OPUNetGameServer.pch</PrecompiledHeaderOutputFile>
<ObjectFileName>.\Release\</ObjectFileName>
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Midl>
<TypeLibraryName>.\Release\OPUNetGameServer.tlb</TypeLibraryName>
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OBJDIR := $(BUILDDIR)/obj
DEPDIR := $(BUILDDIR)/deps
OUTPUT := $(BINDIR)/netfixserver

CFLAGS := -std=c++11 -g -Wall -Wno-unknown-pragmas
CFLAGS := -std=c++17 -g -Wall -Wno-unknown-pragmas
LDFLAGS := -lstdc++ -lm

DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
Expand Down

0 comments on commit 525305a

Please sign in to comment.