mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-13 10:42:56 +01:00
added new API for AddDefaultLogger to API
This commit is contained in:
parent
b7704b1ed7
commit
fbddb5a5ca
18
API.markdown
18
API.markdown
@ -89,6 +89,24 @@ A logging sink is not required to be a subclass of a specific type. The only req
|
||||
|
||||
### Using the default sink
|
||||
Sink creation is defined in [logworker.hpp](src/g3log/logworker.hpp) and used in [logworker.cpp](src/logworker.cpp). For in-depth knowlege regarding sink implementation details you can look at [sinkhandle.hpp](src/g3log/sinkhandle.hpp) and [sinkwrapper.hpp](src/g3log/sinkwrapper.hpp)
|
||||
```
|
||||
std::unique_ptr<FileSinkHandle> addDefaultLogger(
|
||||
const std::string& log_prefix
|
||||
, const std::string& log_directory
|
||||
, const std::string& default_id = "g3log");
|
||||
```
|
||||
|
||||
With the default id left as is (i.e. "g3log") a creation of the logger in the unit test "test_filechange" would look like this
|
||||
```
|
||||
const std::string directory = "./";
|
||||
const std::string name = "(ReplaceLogFile)";
|
||||
auto worker = g3::LogWorker::createLogWorker();
|
||||
auto handle = worker->addDefaultLogger(name, directory);
|
||||
```
|
||||
The resulting filename would be something like:
|
||||
```
|
||||
./(ReplaceLogFile).g3log.20160217-001406.log
|
||||
```
|
||||
|
||||
|
||||
## LOG <a name="log_flushing">flushing</a>
|
||||
|
@ -154,11 +154,12 @@ int main(int argc, char* argv[]) {
|
||||
testing_helpers::ScopedOut scopedCerr(std::cerr, &cerrDump);
|
||||
|
||||
auto worker = g3::LogWorker::createLogWorker();
|
||||
auto handle = worker->addDefaultLogger(kReplaceFileName, name_path_1, "kjell");
|
||||
auto handle = worker->addDefaultLogger(kReplaceFileName, name_path_1);
|
||||
g_logger_ptr = worker.get();
|
||||
g_filesink_handler = handle.get();
|
||||
last_log_file = g_filesink_handler->call(&g3::FileSink::fileName).get();
|
||||
//cleaner.addLogToClean(last_log_file);
|
||||
std::cout << "log file at: " << last_log_file << std::endl;
|
||||
cleaner.addLogToClean(last_log_file);
|
||||
|
||||
|
||||
g3::initializeLogging(g_logger_ptr);
|
||||
@ -173,6 +174,6 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
std::cout << "FINISHED WITH THE TESTING" << std::endl;
|
||||
// cleaning up
|
||||
//cleaner.addLogToClean(last_log_file);
|
||||
cleaner.addLogToClean(last_log_file);
|
||||
return return_value;
|
||||
}
|
Loading…
Reference in New Issue
Block a user