fixing up log entries
[nodejs-repoproxy.git] / lib / repo-apt.js
index de2c1c7..814f260 100644 (file)
@@ -2,14 +2,15 @@ var fs = require("fs");
 var http = require("http");
 var url = require("url");
 var path = require("path");
+var log = require("./log.js");
 
 function maintain(name, repoinfo, files) {
-       //console.log("doing apt clean for ", repoinfo);
+       //log.debug("doing apt clean for ", repoinfo);
        
        var topdir = path.normalize(global.repoproxy.cacheDir + "/" + name + "/");
        
        function fileCheck(i) {
-               console.log("checking file: ", files[i]);
+               log.debug("checking file: ", files[i]);
                
                var cfile = files[i].replace(topdir, "");
                var ctime_t = new Date();
@@ -20,26 +21,26 @@ function maintain(name, repoinfo, files) {
                // file checks go here
                if(typeof global.repoproxy.downloads[files[i]] != "undefined" && global.repoproxy.downloads[files[i]] == 1) {
                        // ignore this file as its being downloaded
-                       console.log("not checking file because its downloading ", cfile);
+                       log.debug("not checking file because its downloading ", cfile);
                        if(typeof files[i+1] != "undefined") fileCheck(i+1);
                } else {
                        fs.stat(files[i], function(err, stats) {
                                
-                               //console.log("deep check", cfile);
+                               //log.debug("deep check", cfile);
                                if(cfile.match(/.*dists\/.*/) != null) {
                                        // its a dist file, probably, check age and erase if necessary
                                        if(stats["mtime"].getTime() < time_ui) {
                                                // erase file
-                                               console.log("unlinking file for time_ui: ", files[i])
+                                               log.debug("unlinking file for time_ui: ", files[i])
                                                //fs.unlink(files[i]);
                                        } else {
-                                               //console.log("times for file '%s', '%s', '%s', '%s'", cfile, time_ui, time_et, stats["mtime"].getTime());
+                                               //log.debug("times for file '%s', '%s', '%s', '%s'", cfile, time_ui, time_et, stats["mtime"].getTime());
                                        }
                                        
                                } else {
                                        // its just some other file, check the read time
                                        if(stats["atime"].getTime() < time_et) {
-                                               console.log("unlinking file for time_et: ", files[i]);
+                                               log.debug("unlinking file for time_et: ", files[i]);
                                        }
                                }
                                if(typeof files[i+1] != "undefined") fileCheck(i+1);                            
@@ -51,7 +52,7 @@ function maintain(name, repoinfo, files) {
        
        
        if(typeof files[0] != 'undefined') fileCheck(0)
-       else console.log("Skipping (apt) file check as there are none... apprently?");
+       else log.debug("Skipping (apt) file check as there are none... apprently?");
 }
 
 exports.maintain = maintain;
\ No newline at end of file