|
35 | 35 | #include <new>
|
36 | 36 |
|
37 | 37 | #include "filemanager.hpp"
|
| 38 | +#include "proj/internal/internal.hpp" |
38 | 39 | #include "proj/internal/io_internal.hpp"
|
39 | 40 | #include "proj_experimental.h"
|
40 | 41 | #include "proj_internal.h"
|
@@ -88,11 +89,25 @@ pj_ctx pj_ctx::createDefault() {
|
88 | 89 |
|
89 | 90 | const char *projDebug = getenv("PROJ_DEBUG");
|
90 | 91 | if (projDebug != nullptr) {
|
91 |
| - const int debugLevel = atoi(projDebug); |
92 |
| - if (debugLevel >= -PJ_LOG_TRACE) |
93 |
| - ctx.debug_level = debugLevel; |
94 |
| - else |
95 |
| - ctx.debug_level = PJ_LOG_TRACE; |
| 92 | + if (NS_PROJ::internal::ci_equal(projDebug, "ON")) { |
| 93 | + ctx.debug_level = PJ_LOG_DEBUG; |
| 94 | + } else if (NS_PROJ::internal::ci_equal(projDebug, "OFF")) { |
| 95 | + ctx.debug_level = PJ_LOG_ERROR; |
| 96 | + } else if (projDebug[0] == '-' || |
| 97 | + (projDebug[0] >= '0' && projDebug[0] <= '9')) { |
| 98 | + const int debugLevel = atoi(projDebug); |
| 99 | + // Negative debug levels mean that we first start logging when errno |
| 100 | + // is set Cf |
| 101 | + // https://github.com/OSGeo/PROJ/commit/1c1d04b45d76366f54e104f9346879fd48bfde8e |
| 102 | + // This isn't documented for now. Not totally sure we really want |
| 103 | + // that... |
| 104 | + if (debugLevel >= -PJ_LOG_TRACE) |
| 105 | + ctx.debug_level = debugLevel; |
| 106 | + else |
| 107 | + ctx.debug_level = PJ_LOG_TRACE; |
| 108 | + } else { |
| 109 | + fprintf(stderr, "Invalid value for PROJ_DEBUG: %s\n", projDebug); |
| 110 | + } |
96 | 111 | }
|
97 | 112 |
|
98 | 113 | return ctx;
|
|
0 commit comments