Your message has been delivered
Watch Star Fork

weiboad / fierysdkPHPApache-2.0

Clone or download
徐长龙 authored 2017-07-14 15:47 update readme
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading... 7.59 KB


Latest Stable Version Latest Unstable Version License

Other Laguage Introduce: 中文文档


  • for the complex system online tracing.
  • support online debug.level log.exception and error collect.performance monitor and depend reloation picture
  • for the


  • PHP5.3+ with bcmath
  • charset utf-8 project

Step 1 Container Variable


copy the nginx/fiery_fastcgi_pararms -> nginx/conf and edit the vhost config

    listen 80;
    charset utf-8;
    root /path/xxx/xxx/src/public;
    location /{
        index index.php index.html index.htm;
        if (-f $request_filename) {
        if (-d $request_filename) {
        if ($request_filename !~ (\.css|images|index\.php.*) ) {
            rewrite ^/(.*)$ /index.php/$1 last;

    location ~ /index.php/ {
        fastcgi_index index.php;
        include fastcgi_params;
        include fiery_fastcgi_params; # here is the point
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_read_timeout 600;

    location ~ \.php$ {
        fastcgi_index index.php;
        include fastcgi_params;
        include fiery_fastcgi_params; # here is the point
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_read_timeout 600;
# reload the nginx config
nginx -s reload

<VirtualHost *:80>
    DocumentRoot "e:\wwwroot\demo"
    ErrorLog "logs/"
    CustomLog "logs/" common
    # start config the variable for fierysdk
    SetEnv RAGNAR_LOGPATH /data1/ragnar/  # here is the point
    SetEnv RAGNAR_IDC 0  # here is the point
    SetEnv RAGNAR_IP  # here is the point

    <Directory "e:\wwwroot\demo">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

Fierysdk Install

Run command to get this composer

composer require weiboad/fierysdk

insert code on the bootstrap of php project

    use \Adinf\RagnarSDK\RagnarSDK as RagnarSDK;
    use \Adinf\RagnarSDK\RagnarConst as RagnarConst;
    //for the Temporary disable this sdk
    //default log level is info you can Temporary open the debug level by send header
    //filter url
    //when the url contained parameter on path such as 
    //$uid(an var alway change)/fetch 
    //you must write an rule on this callback filted to
    RagnarSDK::setUrlFilterCallback(function ($url, $hashquery) {
        if (trim($url) == "") {
            return "";
        if (stripos($url, 'http') !== 0) {
            $url = "http://" . $url;

        $urlinfo = parse_url($url);

            return $url."#PARSERERROR";

        if (!isset($urlinfo["scheme"])) {
            $urlinfo["scheme"] = "http";

        if (!isset($urlinfo["path"])) {
            $urlinfo["path"] = "/";

        if (!isset($urlinfo["query"])) {
            $urlinfo["query"] = "";

        if ($hashquery) {
            return $urlinfo["scheme"] . "://" . $urlinfo["host"] . $urlinfo["path"] . "?" . $urlinfo["query"];
        } else {
            return $urlinfo["scheme"] . "://" . $urlinfo["host"] . $urlinfo["path"];
    //this must run at latest
    //ragnar_projectname is you project name will use on log folder name
    //Ragnar level log example
    // this is info log you can see this on tracing page on fiery 
    RagnarSDK::RecordLog(RagnarConst::LOG_TYPE_INFO, __FILE__, __LINE__, "module1_msg", array("msg"=>"i wish i can fly!"));
    // this is debug log 
    RagnarSDK::RecordLog(RagnarConst::LOG_TYPE_DEBUG, __FILE__, __LINE__, "module2_msg",array("msg"=>"i wish im rich!");
    //customize performance dig point example will display on tracing page on fiery
    //dig start
    $digpooint = RagnarSDK::digLogStart(__FILE__,__LINE__,"ragnar_test");
        //run something.....
    //dig end

Ragnar level log

  • level log:set the log level to decide the customize log to dump
  • log search:all the log in the level will be show on the tracing page.
  • exception and error:will be show on the error statistic page
  • performance:a easy way the record the function cost time and make an statistics on curl mysql api

log level

  • LOG_TYPE_TRACE trace log for the low level debug
  • LOG_TYPE_DEBUG Debug log
  • LOG_TYPE_NOTICE notice log on the system
  • LOG_TYPE_INFO info for the tips the working status
  • LOG_TYPE_ERROR when the system error will record this level
  • LOG_TYPE_EMEGENCY emegency log that will send SMS or Email to admin
  • LOG_TYPE_EXCEPTION Exception log
  • LOG_TYPE_PERFORMENCE performance log all the dig point will use this

Curl dig point

curl dig point

    //curl must fill
    $digpooint = RagnarSDK::digLogStart(__FILE__, __LINE__, "curl");
    //curl init ....
    $nextrpcidheader = RagnarSDK::getCurlChildCallParam($digpooint);
    curl_setopt($this->ch, CURLOPT_HTTPHEADER, $nextrpcidheader);
    $result = //curl exec ...
    $ext = array("errorno" => $errno, "error" => curl_error($this->ch));
    $info = curl_getinfo($this->ch);
    //digCurlEnd($digPoint, $url, $method, $postParam, $getParam, $curlInfo, $errCode, $errMsg, $result)
    RagnarSDK::digLogEnd($digpooint, array(
                "url" => $info['url'], "method" => self::get_method(),
                "param" => array("post" => $this->post_fields, "get" => $this->query_fields),
                "info" => $info,
                "error" => $ext,
                "result" => json_decode($result,true),//must array


Mysql dig point

    //this for record the exception when the error
    RagnarSDK::RecordLog(\Adinf\Ragnar\Ragnar::LOG_TYPE_EXCEPTION, __FILE__, __LINE__, "mysql", array("fun" => "query", "sql" => $sql, "error" => $ex->getMessage()));
    //start monitor the performance
    $digpooint = RagnarSDK::digLogStart(__FILE__, __LINE__, "mysql");
    //do some sql execute
    //for the mysql performance dig point end
    //RagnarSDK::digLogEnd($digpooint, array("sql" => $sql, "data" => "sql的参数", "op" => "select\delete\update\...", "fun" => "execute_sql"));
    RagnarSDK::digMysqlEnd($digPoint, $sql, "sql的参数", "select\delete\update\...", "execute_sql");
    //if is error
        RagnarSDK::RecordLog(RagnarSDK::LOG_TYPE_EXCEPTION, __FILE__, __LINE__, "mysql", array("fun" => "execute", "sql" => $sql, "error" => $error));

Temporary change

online change the log level by send header

    X-RAGNAR-TRACEID   traceid
    X-RAGNAR-RPCID     rpcid (spanid)
    X-RAGNAR-LOGLEVEL  log level

Comments ( 0 )

You need to Sign in for post a comment

4_float_left_people 4_float_left_close