Fixed log flag for api/cyclic-hash

This commit is contained in:
xdrm-brackets 2017-01-30 10:59:52 +01:00
parent 390312ad41
commit 68d82b9218
5 changed files with 17 additions and 17 deletions

View File

@ -10,7 +10,7 @@
$url = @file_get_contents(URL_CONF);
if( $url === false ){
slog("Cannot find server's api url", 'api:sync');
slog("Cannot find server's api url", 'api:sync','update');
return 127;
}
@ -18,7 +18,7 @@
$hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash');
if( strlen($hash) != 128 ){
slog("Wrong cyclic-hash:hash hash length (".strlen($hash).")", 'api:sync');
slog("Wrong cyclic-hash:hash hash length (".strlen($hash).")", 'api:sync','update');
return 127;
}
@ -26,7 +26,7 @@
$new = syscall(SOURCE_DIR.'/lib/cyclic-hash/new');
if( $new === false ){
slog("cyclic-hash:new returned $new EXIT_STATUS", 'api:sync');
slog("cyclic-hash:new returned $new EXIT_STATUS", 'api:sync','update');
return 127;
}
@ -37,7 +37,7 @@
$data = json_decode(syscall(SOURCE_DIR.'/lib/api/fetch'));
if( is_null($data) ){
slog("api:fetch returned unreadable content", 'api:sync');
slog("api:fetch returned unreadable content", 'api:sync','update');
$data = [];
}
@ -99,7 +99,7 @@
/* (3) Return response as result */
if( $response === false ){
slog("Request error", 'api:sync');
slog("Request error", 'api:sync','update');
return 127;
}
@ -110,7 +110,7 @@
$decr = syscall(SOURCE_DIR.'/lib/cyclic-hash/decr');
if( $decr === false ){
slog("cyclic-hash:decr returned $decr EXIT_STATUS", 'api:sync');
slog("cyclic-hash:decr returned $decr EXIT_STATUS", 'api:sync','update');
return 127;
}

View File

@ -40,10 +40,10 @@
// Try to override the secret file
if( @file_put_contents(SECRET_CONF, $secret) ){
slog("Random secret generated successfully", 'cyclic-hash:decr');
slog("Random secret generated successfully", 'cyclic-hash:decr', 'update');
return 0;
}else{
slog("Error while generating new random secret", 'cyclic-hash:decr');
slog("Error while generating new random secret", 'cyclic-hash:decr', 'update');
return 127;
}
}
@ -63,10 +63,10 @@
/* (2) Try to override the secret file */
if( @file_put_contents(SECRET_CONF, "$key:$depth:$next") ){
slog("Secret depth decremented to $depth", 'cyclic-hash:decr');
slog("Secret depth decremented to $depth", 'cyclic-hash:decr', 'update');
return 0;
}else{
slog("Error while decrementing secret depth", 'cyclic-hash:decr');
slog("Error while decrementing secret depth", 'cyclic-hash:decr', 'update');
return 127;
}
@ -80,10 +80,10 @@
// Try to override the secret file
if( @file_put_contents(SECRET_CONF, $secret) ){
slog("Random secret generated successfully", 'cyclic-hash:decr');
slog("Random secret generated successfully", 'cyclic-hash:decr', 'update');
return 0;
}else{
slog("Error while generating new random secret", 'cyclic-hash:decr');
slog("Error while generating new random secret", 'cyclic-hash:decr', 'update');
return 127;
}

View File

@ -31,7 +31,7 @@
$hash = hash('sha512', $hash);
slog("Returning hash with $depth depth", 'cyclic-hash:hash');
slog("Returning hash with $depth depth", 'cyclic-hash:hash', 'update');
return $hash;
}

View File

@ -14,7 +14,7 @@
/* (2) Check secret file format */
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+):(.{".SECRET_SIZE."})$/", $secret, $match) ){
slog("Error while reading secret", 'cyclic-hash:new');
slog("Error while reading secret", 'cyclic-hash:new', 'update');
return 127;
}
@ -26,7 +26,7 @@
/* (4) Die if not token not changed */
if( $depth > 1 ){
slog("No new secret with $depth depth", 'cyclic-hash:new');
slog("No new secret with $depth depth", 'cyclic-hash:new', 'update');
return 0;
}
@ -40,7 +40,7 @@
for( $d = 0 ; $d < 1000 ; $d++ )
$newhash = hash('sha512', $newhash);
slog("New secret with $depth depth", 'cyclic-hash:new');
slog("New secret with $depth depth", 'cyclic-hash:new', 'update');
return $newhash;
}

View File

@ -21,7 +21,7 @@
/* [2] Log management
=========================================================*/
function slog($message="unknown error...", $feature="default", $flag="daemon"){
function slog($message="unknown error", $feature="main", $flag="daemon"){
file_put_contents(LOG_DIR."/$flag.log", time()." [$feature] $message\n", FILE_APPEND);