Merge lp:~thomas-voss/location-service/fix-1349704 into lp:location-service/trunk

Proposed by Thomas Voß
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 74
Merged at revision: 76
Proposed branch: lp:~thomas-voss/location-service/fix-1349704
Merge into: lp:location-service/trunk
Diff against target: 63 lines (+25/-2)
3 files modified
CMakeLists.txt (+1/-1)
debian/control (+1/-0)
src/location_service/com/ubuntu/location/service/daemon_main.cpp (+23/-1)
To merge this branch: bzr merge lp:~thomas-voss/location-service/fix-1349704
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Manuel de la Peña (community) Approve
Pete Woods Pending
Review via email: mp+228653@code.launchpad.net

This proposal supersedes a proposal from 2014-07-29.

Commit message

Make sure that logging directories are created on service startup.

Description of the change

Make sure that logging directories are created on service startup.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-07-18 11:00:32 +0000
3+++ CMakeLists.txt 2014-07-29 11:23:08 +0000
4@@ -20,7 +20,7 @@
5 include(GNUInstallDirs)
6
7 find_package(PkgConfig)
8-find_package(Boost COMPONENTS system program_options)
9+find_package(Boost COMPONENTS filesystem system program_options)
10 find_package(GLog)
11 find_package(GFlags)
12 find_package(Threads)
13
14=== modified file 'debian/control'
15--- debian/control 2014-07-18 15:31:14 +0000
16+++ debian/control 2014-07-29 11:23:08 +0000
17@@ -15,6 +15,7 @@
18 # in libstdc++ causing us issues, we explicitly select a G++
19 # version.
20 g++-4.9,
21+ libboost-filesystem-dev,
22 libboost-program-options-dev,
23 libboost-system-dev,
24 libdbus-1-dev,
25
26=== modified file 'src/location_service/com/ubuntu/location/service/daemon_main.cpp'
27--- src/location_service/com/ubuntu/location/service/daemon_main.cpp 2014-06-27 07:20:19 +0000
28+++ src/location_service/com/ubuntu/location/service/daemon_main.cpp 2014-07-29 11:23:08 +0000
29@@ -20,12 +20,34 @@
30
31 #include <com/ubuntu/location/logging.h>
32
33+#include <boost/filesystem.hpp>
34+
35 namespace location = com::ubuntu::location;
36
37+namespace
38+{
39+// The directory we put log files in.
40+constexpr const char* log_dir{"/var/log/ubuntu-location-service"};
41+}
42+
43 int main(int argc, char** argv)
44 {
45 // Setup logging for the daemon.
46- FLAGS_log_dir = "/var/log/ubuntu-location-service";
47+ boost::system::error_code ec;
48+ boost::filesystem::create_directories(boost::filesystem::path{log_dir}, ec);
49+
50+ // According to http://www.boost.org/doc/libs/1_55_0/libs/filesystem/doc/reference.html#create_directories
51+ // Creation failure because p resolves to an existing directory shall not be treated as an error.
52+ // With that, we are free to check the error condition and adjust to stderr
53+ // logging accordingly.
54+ if (ec)
55+ {
56+ FLAGS_logtostderr = true;
57+ LOG(WARNING) << "Problem creating directory for log files: " << ec << "."
58+ << "Falling back to stderr logging.";
59+ }
60+
61+ FLAGS_log_dir = log_dir;
62 FLAGS_stop_logging_if_full_disk = true;
63 FLAGS_max_log_size = 5;
64

Subscribers

People subscribed via source and target branches