blob: 7eae514b176535675c0cd565b4799a510cddd758 [file] [log] [blame]
scroggo@google.com9a412522012-09-07 15:21:18 +00001/*
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
tfarinaf168b862014-06-19 12:32:29 -07008#include "BenchLogger.h"
9
scroggo@google.com9a412522012-09-07 15:21:18 +000010#include "SkStream.h"
11
tfarinaf168b862014-06-19 12:32:29 -070012BenchLogger::BenchLogger()
halcanary96fcdcc2015-08-27 07:41:13 -070013: fFileStream(nullptr) {}
scroggo@google.com9a412522012-09-07 15:21:18 +000014
tfarinaf168b862014-06-19 12:32:29 -070015BenchLogger::~BenchLogger() {
scroggo@google.com9a412522012-09-07 15:21:18 +000016 if (fFileStream) {
halcanary385fe4d2015-08-26 13:07:48 -070017 delete fFileStream;
scroggo@google.com9a412522012-09-07 15:21:18 +000018 }
19}
20
tfarinaf168b862014-06-19 12:32:29 -070021bool BenchLogger::SetLogFile(const char *file) {
halcanary385fe4d2015-08-26 13:07:48 -070022 fFileStream = new SkFILEWStream(file);
scroggo@google.com9a412522012-09-07 15:21:18 +000023 return fFileStream->isValid();
24}
25
tfarinaf168b862014-06-19 12:32:29 -070026void BenchLogger::fileWrite(const char msg[], size_t size) {
scroggo@google.com9a412522012-09-07 15:21:18 +000027 if (fFileStream && fFileStream->isValid()) {
28 fFileStream->write(msg, size);
29 }
30}