180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2012 Google Inc. 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkBenchLogger.h" 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkStream.h" 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkBenchLogger::SkBenchLogger() 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru: fFileStream(NULL) {} 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkBenchLogger::~SkBenchLogger() { 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fFileStream) { 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkDELETE(fFileStream); 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querubool SkBenchLogger::SetLogFile(const char *file) { 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fFileStream = SkNEW_ARGS(SkFILEWStream, (file)); 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return fFileStream->isValid(); 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkBenchLogger::fileWrite(const char msg[], size_t size) { 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fFileStream && fFileStream->isValid()) { 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fFileStream->write(msg, size); 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 31