Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request VR-Group/unreal-development/plugins/universallogging!16
  • Loading branch information
Jonathan Ehret committed Jan 10, 2022
2 parents 4bb373d + d725792 commit a4247b2
Show file tree
Hide file tree
Showing 19 changed files with 521 additions and 94 deletions.
94 changes: 94 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2020 RWTH Aachen University, Germany,
# Virtual Reality & Immersive Visualisation Group.
#-------------------------------------------------------------------------------

# The include file can be change to either be removed or reference a specific commit.

include:
- project: 'vr-group/unreal-development/unreal-ci'
ref: master
file: '/shared_scripts.yml'

# In this file you are able to configure your plugins pipeline.
# If you want to customize something, either overwrite things that are defined in the shared_scripts repository,
# or remove the "extends" and write your own scripts
#
# If you want your pipeline to run on every commit, just remove the "only" blocks. Keep in mind, that a build
# can take some time.
#
# If you want to alter the unreal-building process two variables are defined for either changing the CLIENT_CONFIG or
# for adding EXTRA_ARGS to the building process
#
# For the generate stage, you can specify needed dependencies in GEN_DEPENDENCIES with [Branch@PluginFolder] as key
# Example:
#
# Generate_Project:
# only: ['web', 'schedules']
# extends: .Generate_Project_
# variables:
# GEN_TEMPLATE_REPO: "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unrealprojecttemplate.git"
# GEN_TEMPLATE_BRANCH: "develop"
# GEN_DEPENDENCIES: "(
# [master@nDisplayExtensions]='https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/ndisplayextensions.git'
# [master@CaveOverlay]='https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-cave-overlay.git'
# )"
#
# You can uncomment the deploy lines to deploy your project to the CAVE/VRDev. This only makes sense, if your plugin works
# with a generated project.

stages:
- generate
- build
# - deploy

Generate_Project:
only: ['web', 'schedules']
extends: .Generate_Project_
variables:
GEN_TEMPLATE_REPO: "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unrealprojecttemplate.git"
GEN_TEMPLATE_BRANCH: "4.26"
GEN_DEPENDENCIES: "(
)"

Build_Windows:
only: ['web', 'schedules']
extends: .Build_Windows_
tags:
- windows
- unreal-4.26
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: "false"
CLIENT_CONFIG: "DebugGame"
needs:
- job: "Generate_Project"
artifacts: true

Build_CentOS:
only: ['web', 'schedules']
extends: .Build_CentOS_
tags:
- centos
- unreal-4.26
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: "false"
CLIENT_CONFIG: "DebugGame"
needs:
- job: "Generate_Project"
artifacts: true

#Deploy_CAVE:
# only: ['web', 'schedules']
# extends: .Deploy_CAVE_
# needs:
# - job: "Build_CentOS"
# artifacts: true
#
#Deploy_Windows:
# only: ['web', 'schedules']
# extends: .Deploy_VRDev_
# needs:
# - job: "Build_Windows"
# artifacts: true
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2020, Virtual Reality & Immersive Visualization Group at RWTH Aachen University
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ UniLog.Log("Message", "StreamName");
UniLog.LogF("StreamName", "Message %s", *variable);
```

### Send Multiple LogStreams to the Same File

You can simply specify the same file name and file path in multiple LogStreams. The output of both streams will be written to this file. This can be useful to have separate streams for errors or warnings. To distinguish the streams, you can use

```cpp
stream->SetPrefix("Warning: "); // No additional space will be added after the prefix, so make sure to add one if you want that
```
to set a prefix that will automatically be added to every message that is written to the file (this will not show up in the on screen log).
### On Screen Logging
You can also display the log messages on screen. This can even be enabled/disabled during runtime. To do this, use the ILogStream interface:
Expand Down
19 changes: 19 additions & 0 deletions Source/UniversalLogging/Private/LogFileManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "LogFileManager.h"

LogFileStream* LogFileManager::GetLogFileStream(FString FilePath, FString FileName)
{
FString Full_Path = FPaths::Combine(FilePath, FileName);
if (Streams.Contains(Full_Path))
return Streams[Full_Path].Get();
else
Streams.Add(Full_Path, MakeUnique<LogFileStream>(FilePath, FileName));
return Streams[Full_Path].Get();
}

LogFileManager::LogFileManager()
{
}

LogFileManager::~LogFileManager()
{
}
17 changes: 17 additions & 0 deletions Source/UniversalLogging/Private/LogFileManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "LogFileStream.h"

class LogFileManager
{
public:
LogFileStream* GetLogFileStream(FString FilePath, FString FileName);

private:
friend class UniversalLoggingImpl;
LogFileManager();
virtual ~LogFileManager();

private:
TMap<FString, TUniquePtr<LogFileStream>> Streams;
};
53 changes: 53 additions & 0 deletions Source/UniversalLogging/Private/LogFileStream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "LogFileStream.h"

#include "HAL/PlatformFilemanager.h"
#include "LogStream.h"
#include "Misc/Paths.h"

LogFileStream::LogFileStream(const FString Filepath, const FString Filename)
: Filepath(Filepath)
, Filename(Filename)
, bIs_Open(false)
, File_Handle(nullptr)
{
}

LogFileStream::~LogFileStream()
{
Close();
}

void LogFileStream::Open()
{
IPlatformFile& platform_file = FPlatformFileManager::Get().GetPlatformFile();
FString file_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir() + Filepath);
platform_file.CreateDirectoryTree(*file_path);
file_path = FPaths::Combine(file_path, Filename);
File_Handle.Reset(platform_file.OpenWrite(*file_path));
if (!File_Handle)
{
UE_LOG(LogUni, Error, TEXT("Universal Logging: The file %s could not be opened for writing."), *file_path);
bIs_Open = false;
return;
}
bIs_Open = true;
}

void LogFileStream::Close()
{
File_Handle.Reset();
bIs_Open = false;
}

bool LogFileStream::GetIsOpen() const
{
return bIs_Open;
}

void LogFileStream::Write(const FString Text)
{
if (!bIs_Open)
Open();
const FTCHARToUTF8 StringUTF8(*Text);
File_Handle->Write(reinterpret_cast<const uint8*>(StringUTF8.Get()), StringUTF8.Length());
}
19 changes: 19 additions & 0 deletions Source/UniversalLogging/Private/LogFileStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

class LogFileStream
{
public:
LogFileStream(const FString Filepath, const FString Filename);
virtual ~LogFileStream();

void Open();
void Close();
bool GetIsOpen() const;
void Write(const FString Text);

private:
const FString Filepath;
const FString Filename;
bool bIs_Open;
TUniquePtr <IFileHandle> File_Handle;
};
Loading

0 comments on commit a4247b2

Please sign in to comment.