diff options
author | Armin Weatherwax | 2011-01-31 17:12:30 +0100 |
---|---|---|
committer | Armin Weatherwax | 2011-01-31 17:12:30 +0100 |
commit | 355328d8ad52776d036e3bac5014f7034d0479fc (patch) | |
tree | 37b6d0190d06a176f02e2bef92d89db48dcb57e1 /linden/indra/newview | |
parent | fix 2 regressions introduced by 76c8494525b8e2b1 (diff) | |
download | meta-impy-355328d8ad52776d036e3bac5014f7034d0479fc.zip meta-impy-355328d8ad52776d036e3bac5014f7034d0479fc.tar.gz meta-impy-355328d8ad52776d036e3bac5014f7034d0479fc.tar.bz2 meta-impy-355328d8ad52776d036e3bac5014f7034d0479fc.tar.xz |
simple log rotate
Diffstat (limited to 'linden/indra/newview')
-rw-r--r-- | linden/indra/newview/llappviewer.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index 0c3c657..9a0295e 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp | |||
@@ -1646,19 +1646,38 @@ bool LLAppViewer::initLogging() | |||
1646 | LLError::initForApplication( | 1646 | LLError::initForApplication( |
1647 | gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "")); | 1647 | gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "")); |
1648 | LLError::setFatalFunction(errorCallback); | 1648 | LLError::setFatalFunction(errorCallback); |
1649 | |||
1650 | // Remove the last ".old" log file. | ||
1651 | std::string old_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, | ||
1652 | "Imprudence.old"); | ||
1653 | LLFile::remove(old_log_file); | ||
1654 | 1649 | ||
1655 | // Rename current log file to ".old" | 1650 | std::string log_name = "Imprudence.log"; |
1656 | std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, | ||
1657 | "Imprudence.log"); | ||
1658 | LLFile::rename(log_file, old_log_file); | ||
1659 | 1651 | ||
1660 | // Set the log file to Imprudence.log | 1652 | const int MAX_ROTATION = 5; |
1653 | for(int i = MAX_ROTATION; 0 < i; i--) | ||
1654 | { | ||
1655 | std::ostringstream current; | ||
1656 | current << "."; | ||
1657 | current << i; | ||
1658 | |||
1659 | std::ostringstream previous; | ||
1660 | if( 1 < i ) | ||
1661 | { | ||
1662 | previous << "."; | ||
1663 | previous << i-1; | ||
1664 | } | ||
1665 | |||
1666 | std::string current_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, | ||
1667 | log_name + current.str()); | ||
1668 | std::string previous_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, | ||
1669 | log_name + previous.str()); | ||
1661 | 1670 | ||
1671 | if (MAX_ROTATION == i) | ||
1672 | { | ||
1673 | LLFile::remove(current_log_file); | ||
1674 | } | ||
1675 | |||
1676 | LLFile::rename(previous_log_file, current_log_file); | ||
1677 | } | ||
1678 | |||
1679 | // Set the log file to Imprudence.log | ||
1680 | std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, log_name); | ||
1662 | LLError::logToFile(log_file); | 1681 | LLError::logToFile(log_file); |
1663 | 1682 | ||
1664 | // *FIX:Mani no error handling here! | 1683 | // *FIX:Mani no error handling here! |