| 62 | } |
| 63 | |
| 64 | void Channel::SetDestFilePath(const std::string& file) { |
| 65 | // file is append only |
| 66 | if (os_.is_open()) os_.close(); |
| 67 | { |
| 68 | std::ifstream fin(file.c_str()); |
| 69 | if (fin.good()) |
| 70 | LOG(WARNING) << "Messages will be appended to an existed file: " << file; |
| 71 | } |
| 72 | os_.open(file.c_str(), std::ios::app); |
| 73 | if (os_.is_open() == false) |
| 74 | LOG(WARNING) << "Cannot open channel file (" << file << ")"; |
| 75 | } |
| 76 | |
| 77 | void Channel::Send(const std::string& message) { |
| 78 | if (stderr_) fprintf(stderr, "%s\n", message.c_str()); |