Skip to content

Instantly share code, notes, and snippets.

@heapwolf heapwolf/54.js
Created Aug 7, 2012

What would you like to do?
var fs = require('fs');
function openAndWriteToSystemLog(writeBuffer, callback) {'/var/log/system.log', 'a', function opened(err, fd) {
if (err) { return callback(err); }
function notifyError(err) {
fs.close(fd, function() {
var bufferOffset = 0,
bufferLength = writeBuffer.length, filePosition = null;
fs.write( fd, writeBuffer, bufferOffset, bufferLength, filePosition, function wrote(err, written) {
if (err) { return notifyError(err); }
fs.close(fd, function() {

This comment has been minimized.

Copy link
Owner Author

heapwolf commented Aug 7, 2012

new Buffer('writing this string'),
function done(err) {
if (err) {
console.log("error while opening and writing:", err.message);
console.log('All done with no errors');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.