Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
53 lines (47 loc) · 1.38 KB

File metadata and controls

53 lines (47 loc) · 1.38 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "hermes/Platform/Logging.h"
#ifdef __ANDROID__
#include <android/log.h>
#elif defined(__APPLE__)
#include <os/log.h>
#else
#include <cstdio>
#endif
#include <cstdarg>
#include <memory>
namespace hermes {
void hermesLog(const char *componentName, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
#ifdef __ANDROID__
__android_log_vprint(ANDROID_LOG_INFO, componentName, fmt, args);
#elif defined(__APPLE__)
static os_log_t hermesLogger = os_log_create("dev.hermesengine", "Default");
// Need to make a copy in order to do the vsprintf trick.
va_list argsCopy;
va_copy(argsCopy, args);
int numChars = vsnprintf(nullptr, 0, fmt, argsCopy);
va_end(argsCopy);
std::unique_ptr<char[]> buffer{new char[numChars + 1]};
int numCharsWritten = vsnprintf(buffer.get(), numChars + 1, fmt, args);
(void)numCharsWritten;
// Log all messages as public here. Hermes will never log private information.
os_log_with_type(
hermesLogger,
OS_LOG_TYPE_INFO,
"%{public}s: %{public}s",
componentName,
buffer.get());
#else
fprintf(stderr, "%s: ", componentName);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
#endif
va_end(args);
}
} // namespace hermes
Morty Proxy This is a proxified and sanitized view of the page, visit original site.