Flutter Engine
The Flutter Engine
BenchLogger.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef BenchLogger_DEFINED
9#define BenchLogger_DEFINED
10
11#include <stdio.h>
14
15class SkFILEWStream;
16
17/**
18 * Class that allows logging to a file while simultaneously logging to stdout/stderr.
19 */
21public:
23
24 /**
25 * Not virtual, since this class is not intended to be subclassed.
26 */
28
29 /**
30 * Specify a file to write progress logs to. Unless this is called with a valid file path,
31 * BenchLogger will only write to stdout/stderr.
32 */
33 bool SetLogFile(const char file[]);
34
35 /**
36 * Log an error to stderr, taking a C style string as input.
37 */
38 void logError(const char msg[]) { this->nativeLogError(msg); }
39
40 /**
41 * Log an error to stderr, taking an SkString as input.
42 */
43 void logError(const SkString& str) { this->nativeLogError(str.c_str()); }
44
45 /**
46 * Log the progress of the bench tool to both stdout and the log file specified by SetLogFile,
47 * if any, taking a C style string as input.
48 */
49 void logProgress(const char msg[]) {
50 this->nativeLogProgress(msg);
51 this->fileWrite(msg, strlen(msg));
52 }
53
54 /**
55 * Log the progress of the bench tool to both stdout and the log file specified by SetLogFile,
56 * if any, taking an SkString as input.
57 */
58 void logProgress(const SkString& str) {
59 this->nativeLogProgress(str.c_str());
60 this->fileWrite(str.c_str(), str.size());
61 }
62
63private:
64#ifdef SK_BUILD_FOR_ANDROID
65 void nativeLogError(const char msg[]) { SkDebugf("%s", msg); }
66#else
67 void nativeLogError(const char msg[]) { fprintf(stderr, "%s", msg); }
68#endif
69 void nativeLogProgress(const char msg[]) { SkDebugf("%s", msg); }
70
71 void fileWrite(const char msg[], size_t size);
72
73 SkFILEWStream* fFileStream;
74};
75
76#endif // BenchLogger_DEFINED
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
bool SetLogFile(const char file[])
Definition: BenchLogger.cpp:21
void logError(const char msg[])
Definition: BenchLogger.h:38
void logError(const SkString &str)
Definition: BenchLogger.h:43
void logProgress(const char msg[])
Definition: BenchLogger.h:49
void logProgress(const SkString &str)
Definition: BenchLogger.h:58
size_t size() const
Definition: SkString.h:131
const char * c_str() const
Definition: SkString.h:133
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