John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Nicolas Capens | cc863da | 2015-01-21 15:50:55 -0500 | [diff] [blame] | 7 | #include "InfoSink.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 8 | |
| 9 | void TInfoSinkBase::prefix(TPrefixType message) { |
| 10 | switch(message) { |
| 11 | case EPrefixNone: |
| 12 | break; |
| 13 | case EPrefixWarning: |
| 14 | sink.append("WARNING: "); |
| 15 | break; |
| 16 | case EPrefixError: |
| 17 | sink.append("ERROR: "); |
| 18 | break; |
| 19 | case EPrefixInternalError: |
| 20 | sink.append("INTERNAL ERROR: "); |
| 21 | break; |
| 22 | case EPrefixUnimplemented: |
| 23 | sink.append("UNIMPLEMENTED: "); |
| 24 | break; |
| 25 | case EPrefixNote: |
| 26 | sink.append("NOTE: "); |
| 27 | break; |
| 28 | default: |
| 29 | sink.append("UNKOWN ERROR: "); |
| 30 | break; |
| 31 | } |
| 32 | } |
| 33 | |
Alexis Hetu | 253fdd1 | 2015-07-07 15:12:46 -0400 | [diff] [blame^] | 34 | void TInfoSinkBase::location(const TSourceLoc& loc) { |
| 35 | int string = loc.first_file, line = loc.first_line; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 36 | |
| 37 | TPersistStringStream stream; |
| 38 | if (line) |
| 39 | stream << string << ":" << line; |
| 40 | else |
| 41 | stream << string << ":? "; |
| 42 | stream << ": "; |
| 43 | |
| 44 | sink.append(stream.str()); |
| 45 | } |
| 46 | |
| 47 | void TInfoSinkBase::message(TPrefixType message, const char* s) { |
| 48 | prefix(message); |
| 49 | sink.append(s); |
| 50 | sink.append("\n"); |
| 51 | } |
| 52 | |
| 53 | void TInfoSinkBase::message(TPrefixType message, const char* s, TSourceLoc loc) { |
| 54 | prefix(message); |
| 55 | location(loc); |
| 56 | sink.append(s); |
| 57 | sink.append("\n"); |
| 58 | } |