Skip to content

Commit

Permalink
Remove initialize function from LogFileStreamOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
YaSuenag committed Aug 25, 2021
1 parent 19bc58c commit bb3f236
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 43 deletions.
13 changes: 7 additions & 6 deletions src/hotspot/share/logging/logFileOutput.cpp
Expand Up @@ -196,12 +196,13 @@ bool LogFileOutput::parse_options(const char* options, outputStream* errstream)
*equals_pos = '\0';

if (strcmp(FoldMultilinesOptionKey, key) == 0) {
// We need to pass <key>=<value> style option to LogFileStreamOutput::initialize().
// Thus we restore '=' temporally.
*equals_pos = '=';
success = LogFileStreamOutput::initialize(pos, errstream);
*equals_pos = '\0';
if (!success) {
if (strcmp(value_str, "true") == 0) {
_fold_multilines = true;
} else if (strcmp(value_str, "false") == 0) {
_fold_multilines = false;
} else {
errstream->print_cr("Invalid option '%s' for %s.", value_str, FoldMultilinesOptionKey);
success = false;
break;
}
} else if (strcmp(FileCountOptionKey, key) == 0) {
Expand Down
34 changes: 0 additions & 34 deletions src/hotspot/share/logging/logFileStreamOutput.cpp
Expand Up @@ -53,40 +53,6 @@ LogFileStreamInitializer::LogFileStreamInitializer() {
}
}

bool LogFileStreamOutput::initialize(const char* options, outputStream* errstream) {
if (options == NULL || strlen(options) == 0) {
return true;
}

char* opts = os::strdup_check_oom(options, mtLogging);
char* equals_pos = strchr(opts, '=');
bool success = false;
if (equals_pos == NULL) {
errstream->print_cr("Invalid option '%s' for log file stream output.", opts);
} else {
char* key = opts;
char* value_str = equals_pos + 1;
*equals_pos = '\0';

if (strcmp(FoldMultilinesOptionKey, key) == 0) {
if (strcmp(value_str, "true") == 0) {
_fold_multilines = true;
success = true;
} else if (strcmp(value_str, "false") == 0) {
_fold_multilines = false;
success = true;
} else {
errstream->print_cr("Invalid option '%s' for %s.", value_str, FoldMultilinesOptionKey);
}
} else {
errstream->print_cr("Invalid option '%s' for log file stream output.", options);
}
}

os::free(opts);
return success;
}

int LogFileStreamOutput::write_decorations(const LogDecorations& decorations) {
int total_written = 0;
char buf[LogDecorations::max_decoration_size + 1];
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/logging/logFileStreamOutput.hpp
Expand Up @@ -42,16 +42,16 @@ static LogFileStreamInitializer log_stream_initializer;
// Base class for all FileStream-based log outputs.
class LogFileStreamOutput : public LogOutput {
private:
bool _fold_multilines;
bool _write_error_is_shown;

int write_internal(const char* msg);
protected:
static const char* const FoldMultilinesOptionKey;
FILE* _stream;
size_t _decorator_padding[LogDecorators::Count];
bool _fold_multilines;

LogFileStreamOutput(FILE *stream) : _fold_multilines(false), _write_error_is_shown(false), _stream(stream) {
LogFileStreamOutput(FILE *stream) : _write_error_is_shown(false), _stream(stream), _fold_multilines(false) {
for (size_t i = 0; i < LogDecorators::Count; i++) {
_decorator_padding[i] = 0;
}
Expand All @@ -61,7 +61,6 @@ class LogFileStreamOutput : public LogOutput {
bool flush();

public:
virtual bool initialize(const char* options, outputStream* errstream);
virtual int write(const LogDecorations& decorations, const char* msg);
virtual int write(LogMessageBuffer::Iterator msg_iterator);
};
Expand Down

0 comments on commit bb3f236

Please sign in to comment.