-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement](Log) Reduce usage of log fatal(PART I) #42344
Changes from 2 commits
3453eb0
ae66093
afeb18b
9b0339c
aaed254
d622461
9290081
e8333c3
8dfe7b6
b5fa54b
16ac0f6
da92d38
1041b96
8894e7d
218eb13
a6ab2f4
81817bd
e833ca3
c9280d4
09e7754
f779030
86df024
d9399f2
86fbcdb
ff496eb
756afe5
3c8028f
c244ccc
4f7a740
fdb6897
cc18a04
f704fb1
da97163
e5dfd18
ac1d12e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -780,7 +780,7 @@ typedef int ssize_t; | |
using std::ostream; | ||
inline ostream& operator<<(ostream& os, const unsigned __int64& num) { | ||
// Fake operator; doesn't actually do anything. | ||
LOG(FATAL) << "64-bit ostream operator << not supported in VC++ 6"; | ||
throw Exception(Statsu::FatalError("64-bit ostream operator << not supported in VC++ 6")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here's a typo? |
||
return os; | ||
} | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,15 @@ | |
#include "gutil/strings/escaping.h" | ||
|
||
#include <assert.h> | ||
#include <glog/logging.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <glog/logging.h> | ||
|
||
#include <limits> | ||
#include <ostream> | ||
|
||
#include "common/exception.h" | ||
|
||
using std::numeric_limits; | ||
#include <vector> | ||
|
||
|
@@ -20,8 +23,8 @@ using std::vector; | |
#include "gutil/integral_types.h" | ||
#include "gutil/port.h" | ||
#include "gutil/stl_util.h" | ||
#include "gutil/utf/utf.h" // for runetochar | ||
#include "gutil/strings/strcat.h" | ||
#include "gutil/utf/utf.h" // for runetochar | ||
|
||
namespace strings { | ||
|
||
|
@@ -143,9 +146,9 @@ int UnescapeCEscapeSequences(const char* source, char* dest, vector<string>* err | |
if (IS_OCTAL_DIGIT(p[1])) // safe (and easy) to do this twice | ||
ch = ch * 8 + *++p - '0'; // now points at last digit | ||
if (ch > 0xFF) | ||
LOG_STRING(ERROR, errors) << "Value of " | ||
<< "\\" << string(octal_start, p + 1 - octal_start) | ||
<< " exceeds 8 bits"; | ||
LOG_STRING(ERROR, errors) | ||
<< "Value of " << "\\" << string(octal_start, p + 1 - octal_start) | ||
<< " exceeds 8 bits"; | ||
*d++ = ch; | ||
break; | ||
} | ||
|
@@ -166,8 +169,8 @@ int UnescapeCEscapeSequences(const char* source, char* dest, vector<string>* err | |
ch = (ch << 4) + hex_digit_to_int(*++p); | ||
if (ch > 0xFF) | ||
LOG_STRING(ERROR, errors) | ||
<< "Value of " | ||
<< "\\" << string(hex_start, p + 1 - hex_start) << " exceeds 8 bits"; | ||
<< "Value of " << "\\" << string(hex_start, p + 1 - hex_start) | ||
<< " exceeds 8 bits"; | ||
*d++ = ch; | ||
break; | ||
} | ||
|
@@ -899,8 +902,7 @@ int Base64UnescapeInternal(const char* src, int szsrc, char* dest, int szdest, | |
// of data bytes that must remain in the input to avoid aborting the | ||
// loop. | ||
#define GET_INPUT(label, remain) \ | ||
label: \ | ||
--szsrc; \ | ||
label : --szsrc; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont re-format it if you didn't change |
||
ch = *src++; \ | ||
decode = unbase64[ch]; \ | ||
if (decode < 0) { \ | ||
|
@@ -1084,7 +1086,8 @@ int Base64UnescapeInternal(const char* src, int szsrc, char* dest, int szdest, | |
|
||
default: | ||
// state should have no other values at this point. | ||
LOG(FATAL) << "This can't happen; base64 decoder state = " << state; | ||
throw doris::Exception( | ||
doris::Status::FatalError("This can't happen; base64 decoder state = {}", state)); | ||
} | ||
|
||
// The remainder of the string should be all whitespace, mixed with | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,15 +10,18 @@ | |||||
#include <ctype.h> | ||||||
#include <errno.h> | ||||||
#include <float.h> // for DBL_DIG and FLT_DIG | ||||||
#include <math.h> // for HUGE_VAL | ||||||
#include <inttypes.h> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead [modernize-deprecated-headers]
Suggested change
|
||||||
#include <math.h> // for HUGE_VAL | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
Suggested change
|
||||||
#include <stdio.h> | ||||||
#include <stdlib.h> | ||||||
#include <string.h> | ||||||
#include <inttypes.h> | ||||||
#include <sys/types.h> | ||||||
|
||||||
#include <limits> | ||||||
#include <ostream> | ||||||
|
||||||
#include "common/exception.h" | ||||||
|
||||||
using std::numeric_limits; | ||||||
#include <string> | ||||||
|
||||||
|
@@ -28,7 +31,6 @@ using std::string; | |||||
#include <fmt/format.h> | ||||||
|
||||||
#include "common/logging.h" | ||||||
|
||||||
#include "gutil/gscoped_ptr.h" | ||||||
#include "gutil/integral_types.h" | ||||||
#include "gutil/stringprintf.h" | ||||||
|
@@ -702,12 +704,16 @@ size_t u64tostr_base36(uint64 number, size_t buf_size, char* buffer) { | |||||
} | ||||||
|
||||||
// Generate functions that wrap safe_strtoXXX_base. | ||||||
#define GEN_SAFE_STRTO(name, type) \ | ||||||
bool name##_base(const string& str, type* value, int base) { \ | ||||||
return name##_base(str.c_str(), value, base); \ | ||||||
} \ | ||||||
bool name(const char* str, type* value) { return name##_base(str, value, 10); } \ | ||||||
bool name(const string& str, type* value) { return name##_base(str.c_str(), value, 10); } | ||||||
#define GEN_SAFE_STRTO(name, type) \ | ||||||
bool name##_base(const string& str, type* value, int base) { \ | ||||||
return name##_base(str.c_str(), value, base); \ | ||||||
} \ | ||||||
bool name(const char* str, type* value) { \ | ||||||
return name##_base(str, value, 10); \ | ||||||
} \ | ||||||
bool name(const string& str, type* value) { \ | ||||||
return name##_base(str.c_str(), value, 10); \ | ||||||
} | ||||||
GEN_SAFE_STRTO(safe_strto32, int32); | ||||||
GEN_SAFE_STRTO(safe_strtou32, uint32); | ||||||
GEN_SAFE_STRTO(safe_strto64, int64); | ||||||
|
@@ -772,8 +778,8 @@ uint64 atoi_kmgt(const char* s) { | |||||
scale = GG_ULONGLONG(1) << 40; | ||||||
break; | ||||||
default: | ||||||
LOG(FATAL) << "Invalid mnemonic: `" << c << "';" | ||||||
<< " should be one of `K', `M', `G', and `T'."; | ||||||
throw doris::Exception(doris::Status::FatalError( | ||||||
"Invalid mnemonic: `{}'; should be one of `K', `M', `G', and `T'.", c)); | ||||||
} | ||||||
} | ||||||
return n * scale; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,14 @@ | |
#include <stdio.h> | ||
#include <string.h> | ||
#include <time.h> // for FastTimeToBuffer() | ||
|
||
#include <algorithm> | ||
#include <iterator> | ||
#include <mutex> | ||
#include <ostream> | ||
|
||
#include "common/exception.h" | ||
|
||
using std::copy; | ||
using std::max; | ||
using std::min; | ||
|
@@ -33,13 +36,12 @@ using std::string; | |
using std::vector; | ||
|
||
#include "common/logging.h" | ||
|
||
#include "gutil/stl_util.h" // for string_as_array, STLAppendToString | ||
#include "gutil/stringprintf.h" | ||
#include "gutil/strings/ascii_ctype.h" | ||
#include "gutil/strings/numbers.h" | ||
#include "gutil/strings/stringpiece.h" | ||
#include "gutil/utf/utf.h" | ||
#include "gutil/stringprintf.h" | ||
|
||
#ifdef OS_WINDOWS | ||
#ifdef min // windows.h defines this to something silly | ||
|
@@ -489,7 +491,7 @@ const char* strstr_delimited(const char* haystack, const char* needle, char deli | |
++haystack; | ||
} | ||
} | ||
LOG(FATAL) << "Unreachable statement"; | ||
throw doris::Exception(doris::Status::FatalError("Unreachable statement")); | ||
return nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont change this. we want always exit on exception here.