-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Borislav Stanimirov | ||
// SPDX-License-Identifier: MIT | ||
// | ||
#include "AndroidSink.hpp" | ||
|
||
#include <jalog/Entry.hpp> | ||
|
||
#include <android/log.h> | ||
|
||
namespace jalog::sinks { | ||
|
||
namespace { | ||
android_LogPriority jalogToAndroid(jalog::Level level) { | ||
switch (level) { | ||
case jalog::Level::Debug: return ANDROID_LOG_DEBUG; | ||
case jalog::Level::Info: return ANDROID_LOG_INFO; | ||
case jalog::Level::Warning: return ANDROID_LOG_WARN; | ||
case jalog::Level::Error: return ANDROID_LOG_ERROR; | ||
case jalog::Level::Critical: return ANDROID_LOG_FATAL; | ||
default: return ANDROID_LOG_DEFAULT; | ||
} | ||
} | ||
} | ||
|
||
void AndroidSink::record(const Entry& entry) { | ||
auto lbl = entry.scope.labelCStr(); | ||
auto txt = entry.text; | ||
|
||
__android_log_print(jalogToAndroid(entry.level), lbl, "%.*s", int(txt.length()), txt.data()); | ||
} | ||
|
||
} |
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,17 @@ | ||
// Copyright (c) Borislav Stanimirov | ||
// SPDX-License-Identifier: MIT | ||
// | ||
#pragma once | ||
#include "API.h" | ||
#include <jalog/Sink.hpp> | ||
|
||
namespace jalog::sinks | ||
{ | ||
|
||
class JALOG_SINKLIB_API AndroidSink final : public Sink | ||
{ | ||
public: | ||
virtual void record(const Entry& entry) override; | ||
}; | ||
|
||
} |
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,15 @@ | ||
// Copyright (c) Borislav Stanimirov | ||
// SPDX-License-Identifier: MIT | ||
// | ||
#pragma once | ||
|
||
#if defined(_WIN32) | ||
#include "WindowsColorSink.hpp" | ||
namespace jalog::sinks { using DefaultSink = WindowsColorSink; } | ||
#elif defined(__ANDROID__) | ||
#include "AndroidSink.hpp" | ||
namespace jalog::sinks { using DefaultSink = AndroidSink; } | ||
#else | ||
#include "AnsiColorSink.hpp" | ||
namespace jalog::sinks { using DefaultSink = AnsiColorSink; } | ||
#endif |
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