Tag Archive for log

jquery console.log

jQuery.fn.log = function (msg) {
      console.log("%s: %o", msg, this);
      return this;
  };

source

Extract IP Addresses From Apache Access Log

cat access.log | grep -o '([0-9]{2,3}.){3}.[0-9]{2,3}' | sort | uniq | wc -l

source

VB.NET Log File

Sub Log(ByVal txt As String)
        'Open a file for writing
        Dim FILENAME As String = Server.MapPath("Log.txt")

        'Get a StreamReader class that can be used to read the file
        Dim objStreamWriter As StreamWriter
        
        objStreamWriter = File.AppendText(FILENAME)

        objStreamWriter.WriteLine(DateTime.Now.ToString() + " >> " + txt)
    
        'Close the stream
        objStreamWriter.Close()
    End Sub

source

Dump var into the file in the scripts’s directory.

$log = fopen( dirname(__FILE__)."/log.txt", "a" );  
ob_start();
var_dump($result);
$data = ob_get_clean();
fwrite($log, $data);
fclose($log);

source

Print Date/Time in DOS Batch File

set DATESTAMP=%DATE:~10,4%_%DATE:~4,2%_%DATE:~7,2%

set TIMESTAMP=%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2%

set DATEANDTIME=%DATESTAMP%_%TIMESTAMP%



echo Today's date is %DATESTAMP%

echo The local time is %TIMESTAMP%

echo Date and time: %DATEANDTIME%

source

Call Web Script From Cron Job and Log Ouput

wget <a href="http://yourdomain.com/script" >http://yourdomain.com/script</a> -O - 2&>1 >> ~/your_log.log

source

Log Events

Public Sub WriteToLog(ByVal Action As String, ByVal Details As String)

Dim strConn As String = System.Configuration.ConfigurationManager.ConnectionStrings("FullConnection").ConnectionString
Dim MySQL As String = "insert into tEventLog(Action,Time,IPAddress,Details) values(@Action,@Time,@IPAddress,@Details)"
Dim MyConn As New SqlConnection(strConn)
Dim Cmd As New SqlCommand(MySQL, MyConn)
Cmd.Parameters.Add(New SqlParameter("@Action", Action))
Cmd.Parameters.Add(New SqlParameter("@Time", Now()))
Cmd.Parameters.Add(New SqlParameter("@IPAddress", Request.UserHostAddress()))
Cmd.Parameters.Add(New SqlParameter("@Details", Details))
Try
MyConn.Open()
Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Catch ex As Exception
Response.Write(ex.Message & ":WriteToLog:" & ex.ToString)
End Try
End Sub

source

Log Errors with Twitter

function tweet_error ($error, $description) {
$username = 'yourusername';
$password = 'yourpassword';
$status = "#$error - $description";
$update_url = 'http://www.twitter.com/statuses/update.xml'; // <a href="http://identi.ca/api/statuses/update.xml" >http://identi.ca/api/statuses/update.xml</a> will use identi.ca instead.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "$update_url");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($curl);
$resultArray = curl_getinfo($curl);
curl_close($curl);
return ($resultArray['http_code'] == 200);
}

source

log flash

function log (page:String) {
var lv:LoadVars = new LoadVars();
var rv:LoadVars = new LoadVars();

lv.page = page;
lv.sendAndLoad ("log.php", rv, "POST");
}

source