forked from Atmosphere-NX/Atmosphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LogManager: implement system module, client api, logging api (Atmosph…
…ere-NX#1617) Some notes: * Unless `atmosphere!enable_log_manager` is true, Nintendo's log manager will be used instead. * This prevents paying memory costs for LM when not enabling logging. * To facilitate this, Atmosphere's log manager has a different program id from Nintendo's. * `atmosphere!enable_htc` implies `atmosphere!enable_log_manager`. * LogManager logs to tma, and the SD card (if `lm!enable_sd_card_logging` is true, which it is by default). * Binary logs are saved to `lm!sd_card_log_output_directory`, which is `atmosphere/binlogs` by default.
- Loading branch information
Showing
94 changed files
with
5,594 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
|
||
#include <stratosphere/diag/diag_log_types.hpp> | ||
#include <stratosphere/diag/diag_log_observer.hpp> | ||
#include <stratosphere/diag/impl/diag_impl_log.hpp> | ||
#include <stratosphere/diag/diag_log.hpp> | ||
#include <stratosphere/diag/diag_sdk_log.hpp> | ||
|
||
#include <stratosphere/diag/impl/diag_utf8_util.hpp> | ||
|
40 changes: 40 additions & 0 deletions
40
libraries/libstratosphere/include/stratosphere/diag/diag_log.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
#include <vapours.hpp> | ||
#include <stratosphere/diag/impl/diag_impl_structured_log.hpp> | ||
|
||
#if defined(AMS_IMPL_ENABLE_LOG) | ||
|
||
#define AMS_LOG(...) AMS_IMPL_STRUCTURED_LOG_IMPL("", ::ams::diag::LogSeverity_Info, 0, __VA_ARGS__) | ||
#define AMS_VLOG(_FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL("", ::ams::diag::LogSeverity_Info, 0, _FMT_, _VL_) | ||
#define AMS_PUT(_MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL("", ::ams::diag::LogSeverity_Info, 0, _MSG_, _ML_) | ||
|
||
#define AMS_STRUCTURED_LOG(_MOD_, _SEV_, _VER_, ...) AMS_IMPL_STRUCTURED_LOG_IMPL(_MOD_, _SEV_, _VER_, __VA_ARGS__) | ||
#define AMS_STRUCTURED_VLOG(_MOD_, _SEV_, _VER_, _FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL(_MOD_, _SEV_, _VER_, _FMT_, _VL_) | ||
#define AMS_STRUCTURED_PUT(_MOD_, _SEV_, _VER_, _MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL(_MOD_, _SEV_, _VER_, _MSG_, _ML_) | ||
|
||
#else | ||
|
||
#define AMS_LOG(...) do { /* ... */ } while (false) | ||
#define AMS_VLOG(_FMT_, _VL_) do { /* ... */ } while (false) | ||
#define AMS_PUT(_MSG_, _ML_) do { /* ... */ } while (false) | ||
|
||
#define AMS_STRUCTURED_LOG(_MOD_, _SEV_, _VER_, ...) do { /* ... */ } while (false) | ||
#define AMS_STRUCTURED_VLOG(_MOD_, _SEV_, _VER_, _FMT_, _VL_) do { /* ... */ } while (false) | ||
#define AMS_STRUCTURED_PUT(_MOD_, _SEV_, _VER_, _MSG_, _ML_) do { /* ... */ } while (false) | ||
|
||
#endif |
41 changes: 41 additions & 0 deletions
41
libraries/libstratosphere/include/stratosphere/diag/diag_log_observer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
#include <vapours.hpp> | ||
#include <stratosphere/diag/diag_log_types.hpp> | ||
|
||
namespace ams::diag { | ||
|
||
using LogObserver = void (*)(const LogMetaData &meta, const LogBody &body, void *arg); | ||
|
||
struct LogObserverHolder { | ||
LogObserver log_observer; | ||
LogObserverHolder *next; | ||
bool is_registered; | ||
void *arg; | ||
}; | ||
|
||
constexpr inline void InitializeLogObserverHolder(LogObserverHolder *holder, LogObserver observer, void *arg) { | ||
holder->log_observer = observer; | ||
holder->next = nullptr; | ||
holder->is_registered = false; | ||
holder->arg = arg; | ||
} | ||
|
||
void RegisterLogObserver(LogObserverHolder *holder); | ||
void UnregisterLogObserver(LogObserverHolder *holder); | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
libraries/libstratosphere/include/stratosphere/diag/diag_log_types.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
#include <vapours.hpp> | ||
|
||
namespace ams::diag { | ||
|
||
enum LogSeverity { | ||
LogSeverity_Trace = 0, | ||
LogSeverity_Info = 1, | ||
LogSeverity_Warn = 2, | ||
LogSeverity_Error = 3, | ||
LogSeverity_Fatal = 4, | ||
}; | ||
|
||
struct SourceInfo { | ||
int line_number; | ||
const char *file_name; | ||
const char *function_name; | ||
}; | ||
|
||
struct LogMetaData { | ||
SourceInfo source_info; | ||
const char *module_name; | ||
LogSeverity severity; | ||
int verbosity; | ||
bool use_default_locale_charset; | ||
void *additional_data; | ||
size_t additional_data_size; | ||
}; | ||
|
||
struct LogBody { | ||
const char *message; | ||
size_t message_size; | ||
bool is_head; | ||
bool is_tail; | ||
}; | ||
|
||
struct LogMessage { | ||
const char *fmt; | ||
std::va_list *vl; | ||
}; | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
libraries/libstratosphere/include/stratosphere/diag/diag_sdk_log.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
#include <vapours.hpp> | ||
#include <stratosphere/diag/impl/diag_impl_structured_log.hpp> | ||
|
||
#if defined(AMS_IMPL_ENABLE_SDK_LOG) | ||
|
||
#define AMS_SDK_LOG(...) AMS_IMPL_STRUCTURED_LOG_IMPL("$", ::ams::diag::LogSeverity_Info, 0, __VA_ARGS__) | ||
#define AMS_SDK_VLOG(_FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL("$", ::ams::diag::LogSeverity_Info, 0, _FMT_, _VL_) | ||
#define AMS_SDK_PUT(_MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL("$", ::ams::diag::LogSeverity_Info, 0, _MSG_, _ML_) | ||
|
||
#else | ||
|
||
#define AMS_SDK_LOG(...) do { /* ... */ } while (false) | ||
#define AMS_SDK_VLOG(_FMT_, _VL_) do { /* ... */ } while (false) | ||
#define AMS_SDK_PUT(_MSG_, _ML_) do { /* ... */ } while (false) | ||
|
||
#endif |
37 changes: 37 additions & 0 deletions
37
libraries/libstratosphere/include/stratosphere/diag/impl/diag_impl_build_config.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
#include <vapours.hpp> | ||
|
||
#if defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING) | ||
#define AMS_IMPL_ENABLE_SDK_LOG | ||
#else | ||
//#define AMS_IMPL_ENABLE_SDK_LOG | ||
#endif | ||
|
||
#if defined(AMS_ENABLE_LOG) | ||
#define AMS_IMPL_ENABLE_LOG | ||
|
||
#if defined(AMS_DISABLE_LOG) | ||
#error "Incoherent log configuration" | ||
#endif | ||
#elif defined(AMS_DISABLE_LOG) | ||
|
||
#elif defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING) | ||
#define AMS_IMPL_ENABLE_LOG | ||
#else | ||
//#define AMS_IMPL_ENABLE_LOG | ||
#endif |
26 changes: 26 additions & 0 deletions
26
libraries/libstratosphere/include/stratosphere/diag/impl/diag_impl_log.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
#include <vapours.hpp> | ||
#include <stratosphere/diag/diag_log_types.hpp> | ||
|
||
namespace ams::diag::impl { | ||
|
||
void LogImpl(const LogMetaData &meta, const char *fmt, ...) __attribute__((format(printf, 2, 3))); | ||
void VLogImpl(const LogMetaData &meta, const char *fmt, std::va_list vl); | ||
void PutImpl(const LogMetaData &meta, const char *msg, size_t msg_size); | ||
|
||
} |
Oops, something went wrong.