/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
#include "log.h"
#define TP(str) tell_object(find_player("ghost"), str+"\n")
/*
 * returns the owner of ob (for error logging)
 * all calls to this should call get_prg_name()
 */
string  get_wiz_name( mixed file )
{
    object  ob;

    if( !previous_object() )
	return "root";
    if( objectp( file ) )
	file = file_name( file );
    file = explode( file, "/" ) - ({ "" });
    if( file[ 0 ] == "w" )
    {
	return file[ 1 ];
    }
    if( file[ 0 ] == "d" )
    {
	return "dom";
    }
    return "root";
}				/* get_wiz_name() */

string  get_dom_name( mixed file )
{
    if( objectp( file ) )
	file = file_name( file );
    file = explode( file, "/" ) - ({ "" });
    if( file[ 0 ] == "d" && sizeof( file ) >= 2 )
	return file[ 1 ];
}				/* get_dom_name() */

/*
 * return the owner of file (for error logging)
 */
string  get_prg_name( mixed file )
{
    object  obj;

    if( objectp( file ) )
	file = file_name( file );
    file = explode( file, "/" ) - ({ "" });
    if( file[ 0 ] == "w" )
	return file[ 1 ];
    return "root";
}				/* get_prg_name() */

/*
 * Write an error message into a log file. The error occured in the object
 * 'file', giving the error message 'message'.
 */

void    log_error( string file, string message )
{
    string  name;

    if( this_player() && this_player()->query_creator() )
    {
	tell_object( this_player(), "E " + message );
    }
    name = get_wiz_name( file );
    if( name == 0 )
    {
	name = "log";
    }
    if( name == "log" )
    {
	log_file( name, message );
    }
    else
	if( name == "dom" )
	{
	    write_file( "/d/" + get_dom_name( file ) + "/error-log", message );
	}
	else
	    if( name != "root" )
	    {
		write_file( "/w/" + name + "/error-log", message );
	    }
}				/* log_error() */

void    do_log( string person, string text )
{
    if( file_name( previous_object() )[ 0..7 ] != "/global/" )
	return;
    rm( "/w/" + person + "/" + PLAYER_ERROR_LOG );
    write_file( "/w/" + person + "/" + PLAYER_ERROR_LOG, text );
}				/* do_log() */

void    forward_error( string file, string text )
{
    if( file_name( previous_object() )[ 0..7 ] != "/global/" )
    {
	return;
    }
    write_file( file, text );
}				/* forward_error() */