From 616d87444313db865c60fbeee36ebe5250ef301e Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 28 Oct 2014 05:36:00 -0200 Subject: New logging system --- src/common/logging/text_formatter.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/common/logging/text_formatter.h (limited to 'src/common/logging/text_formatter.h') diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h new file mode 100644 index 000000000..6c2a6f1ea --- /dev/null +++ b/src/common/logging/text_formatter.h @@ -0,0 +1,26 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Log { + +class Logger; +struct Entry; + +/// Formats a log entry into the provided text buffer. +void FormatLogMessage(const Entry& entry, char* out_text, size_t text_len); +/// Formats and prints a log entry to stderr. +void PrintMessage(const Entry& entry); + +/** + * Logging loop that repeatedly reads messages from the provided logger and prints them to the + * console. It is the baseline barebones log outputter. + */ +void TextLoggingLoop(std::shared_ptr logger); + +} -- cgit v1.2.3 From 6390c66e950b0536c438bf3be1ea78fd0540d6c9 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 4 Nov 2014 03:03:19 -0200 Subject: Implement text path trimming for shorter paths. --- src/common/logging/text_formatter.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/common/logging/text_formatter.h') diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h index 6c2a6f1ea..04164600f 100644 --- a/src/common/logging/text_formatter.h +++ b/src/common/logging/text_formatter.h @@ -12,6 +12,18 @@ namespace Log { class Logger; struct Entry; +/** + * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's + * intended to be used to strip a system-specific build directory from the `__FILE__` macro, + * leaving only the path relative to the sources root. + * + * @param path The input file path as a null-terminated string + * @param root The name of the root source directory as a null-terminated string. Path up to and + * including the last occurence of this name will be stripped + * @return A pointer to the same string passed as `path`, but starting at the trimmed portion + */ +const char* TrimSourcePath(const char* path, const char* root = "src"); + /// Formats a log entry into the provided text buffer. void FormatLogMessage(const Entry& entry, char* out_text, size_t text_len); /// Formats and prints a log entry to stderr. -- cgit v1.2.3 From 0e0a007a2503d468391004c8ea2faae305232345 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 6 Dec 2014 20:00:08 -0200 Subject: Add configurable per-class log filtering --- src/common/logging/text_formatter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/common/logging/text_formatter.h') diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h index 04164600f..d7e298e28 100644 --- a/src/common/logging/text_formatter.h +++ b/src/common/logging/text_formatter.h @@ -11,6 +11,7 @@ namespace Log { class Logger; struct Entry; +class Filter; /** * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's @@ -33,6 +34,6 @@ void PrintMessage(const Entry& entry); * Logging loop that repeatedly reads messages from the provided logger and prints them to the * console. It is the baseline barebones log outputter. */ -void TextLoggingLoop(std::shared_ptr logger); +void TextLoggingLoop(std::shared_ptr logger, const Filter* filter); } -- cgit v1.2.3