blob: 1087e45a56e1cf9b876c7dfdd00d0bfc37e329de [file] [log] [blame]
/*
* Copyright 2013 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.
*/
// Author: Huibao Lin
#include "pagespeed/kernel/base/annotated_message_handler.h"
#include "pagespeed/kernel/base/message_handler.h"
#include "pagespeed/kernel/base/string.h"
#include "pagespeed/kernel/base/string_util.h"
namespace net_instaweb {
AnnotatedMessageHandler::AnnotatedMessageHandler(MessageHandler* handler) :
message_handler_(handler) {
}
AnnotatedMessageHandler::AnnotatedMessageHandler(const GoogleString& annotation,
MessageHandler* handler) :
message_handler_(handler) {
annotation_ = annotation;
}
AnnotatedMessageHandler::~AnnotatedMessageHandler() {
}
void AnnotatedMessageHandler::MessageVImpl(MessageType type, const char* msg,
va_list args) {
GoogleString buffer(annotation_);
FormatTo(&buffer, msg, args);
message_handler_->MessageS(type, buffer);
}
void AnnotatedMessageHandler::MessageSImpl(
MessageType type, const GoogleString& message) {
GoogleString buffer = StrCat(annotation_, message);
message_handler_->MessageS(type, buffer);
}
void AnnotatedMessageHandler::FileMessageVImpl(MessageType type,
const char* filename,
int line,
const char* msg,
va_list args) {
GoogleString buffer(annotation_);
FormatTo(&buffer, msg, args);
message_handler_->FileMessageS(type, filename, line, buffer);
}
void AnnotatedMessageHandler::FileMessageSImpl(
MessageType type, const char* filename, int line,
const GoogleString& message) {
GoogleString buffer = StrCat(annotation_, message);
message_handler_->FileMessageS(type, filename, line, buffer);
}
} // namespace net_instaweb