Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
tonic
common
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
result
GAsyncResult * result
Definition
fl_text_input_plugin.cc:106
format
uint32_t uint32_t * format
Definition
fl_texture_registrar_test.cc:41
message
Win32Message message
Definition
keyboard_unittests.cc:139
tonic
Definition
image_filter.h:14
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
log.h
Generated on Fri Apr 26 2024 06:15:10 for Flutter Engine by
1.9.8