kopia lustrzana https://github.com/c9/core
Adding logging to fs calls
rodzic
48c00026d1
commit
a3feeaefed
|
@ -10,16 +10,17 @@
|
|||
*/
|
||||
//@todo might have to add queueing for safe operations
|
||||
define(function(require, exports, module) {
|
||||
main.consumes = ["vfs", "Plugin", "auth"];
|
||||
main.consumes = ["vfs", "Plugin", "auth", "vfs.log"];
|
||||
main.provides = ["fs"];
|
||||
return main;
|
||||
|
||||
function main(options, imports, register) {
|
||||
var vfs = imports.vfs;
|
||||
var logger = imports["vfs.log"];
|
||||
var Plugin = imports.Plugin;
|
||||
|
||||
var stream = require("./fs.streams")(vfs, options.base, options.baseProc, options.cli);
|
||||
var xhr = options.cli ? stream : require("./fs.xhr")(vfs.rest);
|
||||
var stream = require("./fs.streams")(vfs, options.base, options.baseProc, options.cli, logger);
|
||||
var xhr = options.cli ? stream : require("./fs.xhr")(vfs.rest, logger);
|
||||
var uCaseFirst = require("c9/string").uCaseFirst;
|
||||
var normalize = require("path").normalize;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ define(function(require, exports, module) {
|
|||
var Stream = require("stream").Stream;
|
||||
var PATH = require("path");
|
||||
|
||||
return function(vfs, base, baseProc, cli) {
|
||||
return function(vfs, base, baseProc, cli, logger) {
|
||||
|
||||
var resolvePath = function(path, basePath) {
|
||||
if (path.charAt(0) == "~") {
|
||||
|
@ -33,7 +33,7 @@ return function(vfs, base, baseProc, cli) {
|
|||
if (encoding)
|
||||
options.encoding = encoding;
|
||||
|
||||
console.log("[vfs.stream] Reading file " + path);
|
||||
logger.log("[vfs.stream] Reading file " + path);
|
||||
|
||||
vfs.readfile(resolvePath(path), options, function(err, meta) {
|
||||
if (err)
|
||||
|
@ -72,7 +72,7 @@ return function(vfs, base, baseProc, cli) {
|
|||
var stream = options.stream = new Stream();
|
||||
stream.readable = true;
|
||||
|
||||
console.log("[vfs.stream] Writing file " + path);
|
||||
logger.log("[vfs.stream] Writing file " + path);
|
||||
|
||||
vfs.mkfile(resolvePath(path), options, function(err, meta) {
|
||||
if (err)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
return function(_request) {
|
||||
return function(_request, logger) {
|
||||
|
||||
function request(method, path, body, callback, progress, sync, headers) {
|
||||
// This goes to rest() function in vfs_client.js
|
||||
|
@ -32,7 +32,7 @@ return function(_request) {
|
|||
return callback(err);
|
||||
}
|
||||
|
||||
console.log("[vfs.xhr] Reading file " + path);
|
||||
logger.log("[vfs.xhr] Reading file " + path);
|
||||
|
||||
var headers = metadata ? { "x-request-metadata" : "true" } : null;
|
||||
return request("GET", path, "", function(err, data, res) {
|
||||
|
@ -81,7 +81,7 @@ return function(_request) {
|
|||
if (path.substr(-1) == "/")
|
||||
path = path.substr(0, path.length - 1);
|
||||
|
||||
console.log("[vfs.xhr] Writing file " + path);
|
||||
logger.log("[vfs.xhr] Writing file " + path);
|
||||
|
||||
return request("PUT", path, data, callback, progress, sync);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue