รบกวน เซียน PHP ช่วยหน่อยครับ(ภาค2)

เริ่มโดย Godfather, 17 สิงหาคม 2007, 14:04:31

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

Godfather

ผมมี Error ใน Controlshop รบกวนเซียน PHP ช่วยหน่อยครับ


Warning: error_log(/var/log/www/tep/page_parse_time.log) [function.error-log]: failed to open stream: No such file or directory in d:\ip1\madeatthailand.biz\www\controlshop\includes\classes\logger.php on line 49
Parse Time: 0.858s


และนี่คือโค๊ดที่ระบบแจ้งว่า Error บรรทัด 49 จะเป็นสีแดง

<?php
/*
  $Id: logger.php,v 1.3 2003/06/20 16:23:08 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class logger {
    var $timer_start, $timer_stop, $timer_total;

// class constructor
    function logger() {
      $this->timer_start();
    }

    function timer_start() {
      if (defined("PAGE_PARSE_START_TIME")) {
        $this->timer_start = PAGE_PARSE_START_TIME;
      } else {
        $this->timer_start = microtime();
      }
    }

    function timer_stop($display = 'false') {
      $this->timer_stop = microtime();

      $time_start = explode(' ', $this->timer_start);
      $time_end = explode(' ', $this->timer_stop);

      $this->timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);

      $this->write(getenv('REQUEST_URI'), $this->timer_total . 's');

      if ($display == 'true') {
        return $this->timer_display();
      }
    }

    function timer_display() {
      return '<span class="smallText">Parse Time: ' . $this->timer_total . 's</span>';
    }

    function write($message, $type) {
      error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
    }
  }
?>



ขอบคุณล่วงหน้าสำหรับคำตอบ
[Color = Red]ท่านที่ ว่างงานอยู่กำลังมองหางาน หรือ ท่านที่ต้องการรายได้เสริม เชิญทางนี้ครับ [Color]http://www.thaiseoboard.com/index.php/topic,65120.0.html

EThaiZone

ฟังค์ชั่น error_log มันอยากจะเขียน log ไว้ที่ /var/log/www/tep/page_parse_time.log

แต่มันทำไม่ได้ครับ

งานนี้มี 2 ทางเลือก

1. หาฟังค์ชั่น error_log แล้วไปแก้โค้ดที่มัน
2. ตัดปัญหา // หน้า บรรทัดที่ 49 ไปเลยครับ

ข้อ 2 นี้ // ไปคงไม่เป็นไร เพราะไม่น่าเกี่ยวกะระบบอะไรมาก แค่เก็บ log

Tee++;

อ้างถึงจาก: Godfather ใน 17 สิงหาคม 2007, 14:04:31
ผมมี Error ใน Controlshop รบกวนเซียน PHP ช่วยหน่อยครับ


Warning: error_log(/var/log/www/tep/page_parse_time.log) [function.error-log]: failed to open stream: No such file or directory in d:\ip1\madeatthailand.biz\www\controlshop\includes\classes\logger.php on line 49
Parse Time: 0.858s


และนี่คือโค๊ดที่ระบบแจ้งว่า Error บรรทัด 49 จะเป็นสีแดง

<?php
/*
  $Id: logger.php,v 1.3 2003/06/20 16:23:08 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class logger {
    var $timer_start, $timer_stop, $timer_total;

// class constructor
    function logger() {
      $this->timer_start();
    }

    function timer_start() {
      if (defined("PAGE_PARSE_START_TIME")) {
        $this->timer_start = PAGE_PARSE_START_TIME;
      } else {
        $this->timer_start = microtime();
      }
    }

    function timer_stop($display = 'false') {
      $this->timer_stop = microtime();

      $time_start = explode(' ', $this->timer_start);
      $time_end = explode(' ', $this->timer_stop);

      $this->timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);

      $this->write(getenv('REQUEST_URI'), $this->timer_total . 's');

      if ($display == 'true') {
        return $this->timer_display();
      }
    }

    function timer_display() {
      return '<span class="smallText">Parse Time: ' . $this->timer_total . 's</span>';
    }

    function write($message, $type) {
      error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
    }
  }
?>



ขอบคุณล่วงหน้าสำหรับคำตอบ

คำสั่งการเขียน error log แบบที่ 3 จะเขียนไปใน abs path ที่กำหนด โดยที่ ตอนนี้มันวิ่งผ่าน ค่าที่ ตั้งใน constant
(STORE_PAGE_PARSE_TIME_LOG)

แต่ว่ามันหา path ไม่เจอเลยเขียนไปไม่ได้ path นี้
/var/log/www/tep/page_parse_time.log

แก้ไขโดยการไปสร้างไฟล์ ตาม path ออกมาหรือว่า comment error_log ทิ้งไปเลย
[direct=http://laravel.in.th]Laravel in Thai[/direct]
[direct=http://jquerytips.com]jQueryTips by Tee++;[/direct]
[direct=https://www.facebook.com/jQueryTips]jQueryTips Page[/direct]
[direct=https://www.facebook.com/Laravel.in.th]Laravel in Thai Page[/direct]
[direct=https://twitter.com/Teepluss]Teepluss's Twitter[/direct]


EThaiZone

กำ error_log เป็นฟังค์ชั่นปกติเหรอเนี่ย (ไม่ทันคิดจะค้น)

แนะนำให้แก้พาทหาที่ลง error ครับ

แล้วเปิดดู error ที่ได้

ผมว่า ถ้ามันไม่มีอะไรขัดข้อง ส่วนนี้มันก็ไม่น่าจะทำงานครับ

Godfather

ผมต้องทำไงบ้างรบกวนช่วยบอกด้วยครับ ผมไม่มีความรู้เรื่อง PHP เลย
[Color = Red]ท่านที่ ว่างงานอยู่กำลังมองหางาน หรือ ท่านที่ต้องการรายได้เสริม เชิญทางนี้ครับ [Color]http://www.thaiseoboard.com/index.php/topic,65120.0.html

EThaiZone

แก้ตรง STORE_PAGE_PARSE_TIME_LOG

เป็นพาทที่ต้องการ เช่น

"d:\ip1\madeatthailand.biz\www\controlshop\page_parse_time.log"

เลยก็ได้

คือเอาไว้ไหนก็ได้ที่คิดว่าไฟล์มันจะเขียนได้

แล้วเราอาจลองโหลดมาดูก็ได้

แต่ถ้าตามจริงถ้าคุณไม่ถนัด
ผมว่า

ใส่ //
หน้าบรรทัด 49 ก็จบครับ

เป็นการปิดระบบการบันทึก log ไม่ให้ทำงานอะ