1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "crazy_linker_error.h"
6
7 #include <stdarg.h>
8 #include <string.h>
9 #include <stdio.h>
10
11 #include "crazy_linker_debug.h"
12
13 namespace crazy {
14
Set(const char * message)15 void Error::Set(const char* message) {
16 if (!message)
17 message = "";
18 strlcpy(buff_, message, sizeof(buff_));
19
20 LOG("--- ERROR: %s\n", buff_);
21 }
22
Append(const char * message)23 void Error::Append(const char* message) {
24 if (!message)
25 return;
26 strlcat(buff_, message, sizeof(buff_));
27
28 LOG("--- ERROR: %s\n", buff_);
29 }
30
Format(const char * fmt,...)31 void Error::Format(const char* fmt, ...) {
32 va_list args;
33 va_start(args, fmt);
34 vsnprintf(buff_, sizeof(buff_), fmt, args);
35 va_end(args);
36
37 LOG("--- ERROR: %s\n", buff_);
38 }
39
AppendFormat(const char * fmt,...)40 void Error::AppendFormat(const char* fmt, ...) {
41 va_list args;
42 va_start(args, fmt);
43 size_t buff_len = strlen(buff_);
44 vsnprintf(buff_ + buff_len, sizeof(buff_) - buff_len, fmt, args);
45 va_end(args);
46
47 LOG("--- ERROR: %s\n", buff_);
48 }
49
50 } // namespace crazy
51