don't log full file paths, remove use of KJ_DBG

pull/5/head
Oliver Giles 9 years ago
parent 99fd47de68
commit e7fe117426

@ -19,10 +19,10 @@
#include "laminar.h"
#include "server.h"
#include "conf.h"
#include "log.h"
#include <sys/wait.h>
#include <fstream>
#include <kj/debug.h>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
@ -404,14 +404,14 @@ bool Laminar::loadConfiguration() {
std::shared_ptr<Run> Laminar::queueJob(std::string name, ParamMap params) {
if(!fs::exists(fs::path(homeDir)/"cfg"/"jobs"/name)) {
KJ_LOG(ERROR, "Non-existent job", name);
LLOG(ERROR, "Non-existent job", name);
return nullptr;
}
// attempt to create a workspace for this job if it doesn't exist
if(!fs::exists(fs::path(homeDir)/"run"/name/"workspace")) {
if(!fs::create_directories(fs::path(homeDir)/"run"/name/"workspace")) {
KJ_LOG(ERROR, "Could not create job workspace", name);
LLOG(ERROR, "Could not create job workspace", name);
return nullptr;
}
}
@ -428,7 +428,7 @@ std::shared_ptr<Run> Laminar::queueJob(std::string name, ParamMap params) {
} else if(it->first == "=reason") {
run->reasonMsg = it->second;
} else {
KJ_LOG(ERROR, "Unknown internal job parameter", it->first);
LLOG(ERROR, "Unknown internal job parameter", it->first);
}
it = params.erase(it);
} else
@ -486,7 +486,7 @@ void Laminar::reapAdvance() {
pid_t pid = waitpid(-1, &ret, 0);
// TODO: handle signalled child processes
if(pid > 0) {
KJ_LOG(INFO, "Reaping", pid);
LLOG(INFO, "Reaping", pid);
auto it = activeJobs.get<0>().find(pid);
std::shared_ptr<Run> run = *it;
bool completed = true;
@ -537,16 +537,16 @@ void Laminar::assignNewJobs() {
// create a working directory (different to a workspace!)
fs::path wd = fs::path(homeDir)/"run"/run->name/std::to_string(buildNum);
if(!fs::create_directory(wd)) {
KJ_LOG(ERROR, "Could not create working directory", wd.string());
LLOG(ERROR, "Could not create working directory", wd.string());
break;
}
run->wd = wd.string();
// create an archive directory
fs::path archive = fs::path(homeDir)/"archive"/run->name/std::to_string(buildNum);
if(fs::is_directory(archive)) {
KJ_LOG(WARNING, "Archive directory already exists", archive.string());
LLOG(WARNING, "Archive directory already exists", archive.string());
} else if(!fs::create_directories(archive)) {
KJ_LOG(ERROR, "Could not create archive directory", archive.string());
LLOG(ERROR, "Could not create archive directory", archive.string());
break;
}
@ -596,7 +596,7 @@ void Laminar::assignNewJobs() {
// update next build number
buildNums[run->name] = buildNum;
KJ_LOG(INFO, "Queued job to node", run->name, run->build, node.name);
LLOG(INFO, "Queued job to node", run->name, run->build, node.name);
// notify clients
Json j;
@ -630,7 +630,7 @@ void Laminar::assignNewJobs() {
// trigger the first step of the run
if(stepRun(run)) {
// should never happen
KJ_LOG(INFO, "No steps for run");
LLOG(INFO, "No steps for run");
run->complete();
}
@ -651,7 +651,7 @@ void Laminar::runFinished(const Run * r) {
Node* node = r->node;
node->busyExecutors--;
KJ_LOG(INFO, "Run completed", r->name, to_string(r->result));
LLOG(INFO, "Run completed", r->name, to_string(r->result));
time_t completedAt = time(0);
db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?)")
.bind(r->name, r->build, node->name, r->queuedAt, r->startedAt, completedAt, int(r->result),

@ -0,0 +1,37 @@
///
/// Copyright 2015 Oliver Giles
///
/// This file is part of Laminar
///
/// Laminar is free software: you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// Laminar is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
///
#ifndef _LAMINAR_LOG_H_
#define _LAMINAR_LOG_H_
#include <kj/debug.h>
// Simple override to prevent full paths to source files from
// appearing in log messages. Assumes / is the path separator.
// @see kj/debug.h
#define _LBASENAME(path) strrchr(path, '/') ? strrchr(path, '/') + 1 : path
#define LLOG(severity, ...) \
if (!::kj::_::Debug::shouldLog(::kj::_::Debug::Severity::severity)) {} else \
::kj::_::Debug::log(_LBASENAME(__FILE__), __LINE__, ::kj::_::Debug::Severity::severity, \
#__VA_ARGS__, __VA_ARGS__)
#endif // _LAMINAR_LOG_H_

@ -17,9 +17,9 @@
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
///
#include "laminar.h"
#include "log.h"
#include <signal.h>
#include <kj/debug.h>
std::function<void()> sigHandler;
static void __sigHandler(int) { sigHandler(); }
@ -34,7 +34,7 @@ int main(int argc, char** argv) {
do {
Laminar laminar;
sigHandler = [&](){
KJ_LOG(INFO, "Received SIGINT");
LLOG(INFO, "Received SIGINT");
laminar.stop();
};
signal(SIGINT, &__sigHandler);
@ -43,7 +43,7 @@ int main(int argc, char** argv) {
laminar.run();
} while(false);
KJ_DBG("end of main");
LLOG(INFO, "end of main");
return 0;
}

@ -19,9 +19,9 @@
#include "run.h"
#include "node.h"
#include "conf.h"
#include <iostream>
#include <kj/debug.h>
#include "log.h"
#include <iostream>
#include <unistd.h>
#include <boost/filesystem.hpp>
@ -47,7 +47,7 @@ Run::Run() {
}
Run::~Run() {
KJ_DBG("Run destroyed");
LLOG(INFO, "Run destroyed");
}
std::string Run::reason() const {
@ -103,11 +103,11 @@ bool Run::step() {
}
printf("[laminar] Executing %s\n", currentScript.c_str());
execl(currentScript.c_str(), currentScript.c_str(), NULL);
KJ_LOG(FATAL, "execl returned", strerror(errno));
LLOG(FATAL, "execl returned", strerror(errno));
_exit(1);
}
KJ_LOG(INFO, "Forked", currentScript, pid);
LLOG(INFO, "Forked", currentScript, pid);
close(pfd[1]);
fd = pfd[0];
this->pid = pid;

@ -20,12 +20,12 @@
#include "interface.h"
#include "laminar.capnp.h"
#include "resources.h"
#include "log.h"
#include <capnp/ez-rpc.h>
#include <capnp/rpc-twoparty.h>
#include <capnp/rpc.capnp.h>
#include <kj/async-io.h>
#include <kj/debug.h>
#include <kj/threadlocal.h>
#include <websocketpp/config/core.hpp>
@ -58,9 +58,9 @@ namespace {
LaminarCi::JobResult fromRunState(RunState state) {
switch(state) {
case RunState::SUCCESS: return LaminarCi::JobResult::SUCCESS;
case RunState::FAILED: return LaminarCi::JobResult::FAILED;
case RunState::FAILED: return LaminarCi::JobResult::FAILED;
case RunState::ABORTED: return LaminarCi::JobResult::ABORTED;
default:
KJ_DBG("TODO log state", to_string(state));
return LaminarCi::JobResult::UNKNOWN;
}
}
@ -81,7 +81,7 @@ public:
// Start a job, without waiting for it to finish
kj::Promise<void> trigger(TriggerContext context) override {
std::string jobName = context.getParams().getJobName();
KJ_LOG(INFO, "RPC trigger", jobName);
LLOG(INFO, "RPC trigger", jobName);
ParamMap params;
for(auto p : context.getParams().getParams()) {
params[p.getName().cStr()] = p.getValue().cStr();
@ -96,7 +96,7 @@ public:
// Start a job and wait for the result
kj::Promise<void> start(StartContext context) override {
std::string jobName = context.getParams().getJobName();
KJ_LOG(INFO, "RPC start", jobName);
LLOG(INFO, "RPC start", jobName);
ParamMap params;
for(auto p : context.getParams().getParams()) {
params[p.getName().cStr()] = p.getValue().cStr();
@ -116,7 +116,7 @@ public:
kj::Promise<void> pend(PendContext context) override {
std::string jobName = context.getParams().getJobName();
int buildNum = context.getParams().getBuildNum();
KJ_LOG(INFO, "RPC pend", jobName, buildNum);
LLOG(INFO, "RPC pend", jobName, buildNum);
kj::Promise<RunState> promise = laminar.waitForRun(jobName, buildNum);
@ -129,7 +129,7 @@ public:
kj::Promise<void> set(SetContext context) override {
std::string jobName = context.getParams().getJobName();
int buildNum = context.getParams().getBuildNum();
KJ_LOG(INFO, "RPC set", jobName, buildNum);
LLOG(INFO, "RPC set", jobName, buildNum);
LaminarCi::MethodResult result = laminar.setParam(jobName, buildNum,
context.getParams().getParam().getName(), context.getParams().getParam().getValue())

Loading…
Cancel
Save