blob: 68b4600b99c2b6ee6f6ad86b74c1236a7bccaa1e [file] [log] [blame]
edisonn@google.com67d7fb42013-10-07 15:40:21 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9#include "SkPdfReporter.h"
10
11#include "SkTypes.h"
12
13const char* severityName[] = {
14"Info",
15"CodeWarning",
16"Warning",
17"IgnoreError",
18"Error",
19"FatalError",
20};
21
22const char* getSeverityName(SkPdfIssueSeverity sev) {
23 if (0 <= sev && sev < _kCount__SkPdfIssueSeverity) {
24 return severityName[sev];
25 }
26 SkASSERT(false);
27 return "UNKOWN SEVERITY";
28}
29
30// TODO(edisonn): add a flag to set the minimum warning level
edisonn@google.comd03c2c72013-10-11 18:26:45 +000031// TODO(edisonn): get the address in the file, and report it.
32// TODO(edisonn): build a html file based on warnings which would showe the original pdf
33// content, with tooltips where warnings/errors were reported.
34
edisonn@google.com67d7fb42013-10-07 15:40:21 +000035
36#ifdef PDF_REPORT
edisonn@google.come50d9a12013-10-10 20:58:22 +000037void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue,
38 const char* context,
39 const SkPdfNativeObject* obj,
40 SkPdfContext* pdfContext) {
edisonn@google.com67d7fb42013-10-07 15:40:21 +000041 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
42 printf("%s: %s\n", getSeverityName(sev), context);
43 }
44}
45
edisonn@google.come50d9a12013-10-10 20:58:22 +000046void SkPdfReportIf(bool report,
47 SkPdfIssueSeverity sev, SkPdfIssue issue,
48 const char* context,
49 const SkPdfNativeObject* obj,
50SkPdfContext* pdfContext) {
edisonn@google.com67d7fb42013-10-07 15:40:21 +000051 if (!report) {
52 return;
53 }
54 SkPdfReport(sev, issue, context, obj, pdfContext);
55}
edisonn@google.come50d9a12013-10-10 20:58:22 +000056
57void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev,
58 const char* context,
59 const SkPdfNativeObject* obj,
60 int anyOfTypes, SkPdfContext* pdfContext) {
61 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
62 printf("%s: %s\n", getSeverityName(sev), context);
63 }
64}
65
edisonn@google.com67d7fb42013-10-07 15:40:21 +000066#endif // PDF_REPORT