Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

OS-1759 mkdir /var/log/vm if it doesn't exist and if we can't create …

…it, just log to ring buffer.
  • Loading branch information...
commit 397889a49e44188bb68817c2a3486e3911335887 1 parent ddf692e
@joshwilsdon joshwilsdon authored
Showing with 23 additions and 8 deletions.
  1. +23 −8 src/vm/node_modules/VM.js
View
31 src/vm/node_modules/VM.js
@@ -203,6 +203,14 @@ function ensureLogging(action, side_effects)
var logname;
var streams = [];
+ function start_logging() {
+ VM.log = bunyan.createLogger({
+ name: logname,
+ streams: streams,
+ serializers: bunyan.stdSerializers
+ });
+ }
+
// This is here in case an app calls a lookup first and then a create. The
// logger will get created in no-sideeffects mode for the lookup but when
// the create is called this will force the switch to writing.
@@ -228,9 +236,6 @@ function ensureLogging(action, side_effects)
streams = streams.concat(VM.logger);
}
- filename = '/var/log/vm/' + Date.now(0) + '-'
- + sprintf('%06d', process.pid) + '-' + logname + '.log';
-
// Add the ringbuffer which we'll dump if we switch from not writing to
// writing, and so that they'll show up in dumps.
streams.push({
@@ -239,6 +244,20 @@ function ensureLogging(action, side_effects)
stream: ringbuffer
});
+ try {
+ if (!fs.existsSync('/var/log/vm')) {
+ fs.mkdirSync('/var/log/vm');
+ }
+ } catch (e) {
+ // We can't ever log to a file in /var/log/vm if we can't create it,
+ // so we just log to ring buffer (above).
+ start_logging();
+ return;
+ }
+
+ filename = '/var/log/vm/' + Date.now(0) + '-'
+ + sprintf('%06d', process.pid) + '-' + logname + '.log';
+
if (side_effects) {
streams.push({
level: VM.loglevel,
@@ -252,11 +271,7 @@ function ensureLogging(action, side_effects)
});
}
- VM.log = bunyan.createLogger({
- name: logname,
- streams: streams,
- serializers: bunyan.stdSerializers
- });
+ start_logging();
}
function ltrim(str, chars)
Please sign in to comment.
Something went wrong with that request. Please try again.