AtomicSoft.com Add power to your website!
Home Products Services Support Free
EasyData/SQL
easy-to-use web interface for SQL databases with countless features
AtomicDesk
help desk, FAQ, knowledge base, live support chat - all in one product
Custom programming
Installation
Documentation
HelpDesk
Libraries
Join our newsletter for information on software updates and new releases. You may unsubscribe at any time.



Click here to download plain text source code.

# subroutine name: LOG
# Appends message to log file. Before message timestamp is added.
#
# Global variables used:
#    $no_flock - disable flock or not
sub LOG {
    my ($filename,$message)=@_;
    mkdir("logs", 0777);
    my $existed=-e "logs/$filename.log";
    if (open(LOGFILE, ">>logs/$filename.log")) {
        my $txt=localtime()."|$message\n";
        unless ($no_flock) {
            # Exclusive locking
            flock(LOGFILE, 2) ;
            # In case someone appended while we
            # were waiting, seek to EOF
            seek(LOGFILE, 0, 2);
        }
        print LOGFILE $txt;
        # unlock file
        flock(LOGFILE, 8) unless ($no_flock);
        close(LOGFILE);
        chmod(0666, "logs/$filename.log") unless ($existed);
    }
}
 
Copyright © 1999-2007 Atomicsoft Ltd. All Rights Reserved.