Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
log.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "tonic/common/log.h"
6
7#include <cstdarg>
8#include <cstdio>
9#include <memory>
10
11namespace tonic {
12
13namespace {
14
15std::function<void(const char*)> log_handler;
16
17} // namespace
18
19void Log(const char* format, ...) {
20 va_list ap;
21 va_start(ap, format);
22 int result = vsnprintf(nullptr, 0, format, ap);
23 va_end(ap);
24
25 if (result < 0) {
26 return;
27 }
28
29 int size = result + 1;
30 std::unique_ptr<char[]> message = std::make_unique<char[]>(size);
31 va_start(ap, format);
32 result = vsnprintf(message.get(), size, format, ap);
33 va_end(ap);
34
35 if (result < 0) {
36 return;
37 }
38
39 if (log_handler) {
40 log_handler(message.get());
41 } else {
42 printf("%s\n", message.get());
43 }
44}
45
46void SetLogHandler(std::function<void(const char*)> handler) {
47 log_handler = handler;
48}
49
50} // namespace tonic
GAsyncResult * result
uint32_t uint32_t * format
Dart_NativeFunction function
Definition: fuchsia.cc:51
Win32Message message
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
va_start(args, format)
va_end(args)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
void SetLogHandler(std::function< void(const char *)> handler)
Definition: log.cc:46
void Log(const char *format,...)
Definition: log.cc:19