Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: tools/goopdump/dump_log.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/goopdump/dump_log.h ('k') | tools/goopdump/goopdump.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/goopdump/dump_log.cc
diff --git a/tools/goopdump/dump_log.cc b/tools/goopdump/dump_log.cc
deleted file mode 100644
index 878dfb75aaa3e78901c2239c71787d4acb71b012..0000000000000000000000000000000000000000
--- a/tools/goopdump/dump_log.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2008-2009 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ========================================================================
-
-#include "omaha/tools/goopdump/dump_log.h"
-
-#include <vector>
-
-#include "omaha/common/debug.h"
-#include "omaha/common/file.h"
-
-namespace omaha {
-
-DumpLogHandler::DumpLogHandler() {
-}
-
-DumpLogHandler::~DumpLogHandler() {
-}
-
-
-ConsoleDumpLogHandler::ConsoleDumpLogHandler() {
-}
-
-ConsoleDumpLogHandler::~ConsoleDumpLogHandler() {
-}
-
-void ConsoleDumpLogHandler::WriteLine(const TCHAR* line) {
- _tprintf(_T("%s"), line);
-}
-
-
-DebugDumpLogHandler::DebugDumpLogHandler() {
-}
-
-DebugDumpLogHandler::~DebugDumpLogHandler() {
-}
-
-void DebugDumpLogHandler::WriteLine(const TCHAR* line) {
- ::OutputDebugString(line);
-}
-
-
-FileDumpLogHandler::FileDumpLogHandler() {
-}
-
-FileDumpLogHandler::~FileDumpLogHandler() {
-}
-
-void FileDumpLogHandler::set_filename(const TCHAR* filename) {
- filename_ = filename;
- if (File::Exists(filename_)) {
- File::Remove(filename_);
-
- // Write the UNICODE file marker at the beginning.
- char buf[2] = {0xff, 0xfe};
- WriteBufToFile(buf, 2);
- }
-}
-
-void FileDumpLogHandler::WriteLine(const TCHAR* line) {
- if (filename_.IsEmpty()) {
- return;
- }
-
- WriteBufToFile(line, _tcslen(line) * sizeof(TCHAR));
-}
-
-void FileDumpLogHandler::WriteBufToFile(const void* buf,
- DWORD num_bytes_to_write) {
- HANDLE h = ::CreateFile(filename_,
- GENERIC_WRITE,
- FILE_SHARE_READ,
- NULL,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- if (h == INVALID_HANDLE_VALUE) {
- return;
- }
-
- ::SetFilePointer(h, NULL, NULL, FILE_END);
- DWORD bytes_written = 0;
- ::WriteFile(h, buf, num_bytes_to_write, &bytes_written, NULL);
- ::CloseHandle(h);
-}
-
-
-DumpLog::DumpLog() {
-}
-
-DumpLog::~DumpLog() {
-}
-
-void DumpLog::EnableConsole(bool enable) {
- if (enable) {
- AddLogHandler(&console_handler_);
- } else {
- RemoveLogHandler(&console_handler_);
- }
-}
-
-void DumpLog::EnableDebug(bool enable) {
- if (enable) {
- AddLogHandler(&debug_handler_);
- } else {
- RemoveLogHandler(&debug_handler_);
- }
-}
-
-void DumpLog::AddLogHandler(DumpLogHandler* log_handler) {
- ASSERT1(log_handler);
- std::vector<DumpLogHandler*>::iterator it = log_handlers_.begin();
- for (; it != log_handlers_.end(); ++it) {
- DumpLogHandler* handler = *it;
- if (handler == log_handler) {
- return;
- }
- }
-
- log_handlers_.push_back(log_handler);
-}
-
-void DumpLog::RemoveLogHandler(DumpLogHandler* log_handler) {
- ASSERT1(log_handler);
- std::vector<DumpLogHandler*>::iterator it = log_handlers_.begin();
- for (; it != log_handlers_.end(); ++it) {
- DumpLogHandler* handler = *it;
- if (handler == log_handler) {
- log_handlers_.erase(it);
- return;
- }
- }
-}
-
-void DumpLog::WriteLine(const TCHAR* format, ...) const {
- va_list arg_list;
- va_start(arg_list, format);
-
- CString line;
- line.FormatV(format, arg_list);
- line.Append(_T("\r\n"));
-
- std::vector<DumpLogHandler*>::const_iterator it = log_handlers_.begin();
- for (; it != log_handlers_.end(); ++it) {
- DumpLogHandler* handler = *it;
- handler->WriteLine(line);
- }
-}
-
-} // namespace omaha
-
« no previous file with comments | « tools/goopdump/dump_log.h ('k') | tools/goopdump/goopdump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698