blob: 98423d015072b73cf1c473529e3a4d11e3d15432 [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()
scroggo@google.com9a412522012-09-07 15:21:18 +000013: fFileStream(NULL) {}
14
tfarinaf168b862014-06-19 12:32:29 -070015BenchLogger::~BenchLogger() {
scroggo@google.com9a412522012-09-07 15:21:18 +000016 if (fFileStream) {
17 SkDELETE(fFileStream);
18 }
19}
20
tfarinaf168b862014-06-19 12:32:29 -070021bool BenchLogger::SetLogFile(const char *file) {
scroggo@google.com9a412522012-09-07 15:21:18 +000022 fFileStream = SkNEW_ARGS(SkFILEWStream, (file));
23 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}