Flutter Engine
Loading...
Searching...
No Matches
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
11
namespace
tonic
{
12
13
namespace
{
14
15
std::function<void(
const
char
*)> log_handler;
16
17
}
// namespace
18
19
void
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
46
void
SetLogHandler
(std::function<
void
(
const
char
*)>
handler
) {
47
log_handler =
handler
;
48
}
49
50
}
// namespace tonic
handler
const gchar FlBinaryMessengerMessageHandler handler
Definition
fl_mock_binary_messenger.cc:205
message
G_BEGIN_DECLS GBytes * message
Definition
fl_mock_binary_messenger.h:24
format
uint32_t uint32_t * format
Definition
fl_texture_registrar_test.cc:42
log.h
tonic
Definition
image_filter.h:15
tonic::SetLogHandler
void SetLogHandler(std::function< void(const char *)> handler)
Definition
log.cc:46
tonic::Log
void Log(const char *format,...)
Definition
log.cc:19
third_party
tonic
common
log.cc
Generated on Thu Nov 6 2025 16:11:30 for Flutter Engine by
1.9.8