%h1='Log Routes'

%span
  -foreach(log_routes_classes() as $className)
    %a(href="#{url('debug/LoggerCreate', array('type'=>$className))}")
      .icon-plus
      =$className

%table.table.table-condensed
  %thead
    %tr
      %th='ID'
      %th='Type'
      %th='Enabled'
      %th='Categories'
      %th='Levels'
      %th='Extra fields'
      %th='Actions'
      
  %tbody
    -$configPath = pathCombine(app()->basePath,'config')
    -foreach($routes as $loggerId => $route)
      -$routeConfigFile = pathCombine($configPath,"logger_{$loggerId}.php")
      -$runtimeLogger = is_file($routeConfigFile)
      -$props_keys = get_object_readable($route)
      -$props_keys = array_remove_values($props_keys, array('enabled','categories','levels','except','filter','logs','init','detachBehaviors','enableBehaviors','disableBehaviors'))
      %tr
        %td
          -if($runtimeLogger)
            %a(href="#{url('debug/viewAsText', array('filename'=>$routeConfigFile))}")="$loggerId"
          -else
            ="$loggerId"
        %td=get_class($route)
        %td
          -if($route->enabled)
            %a.color-green.icon-off(href="#{url('debug/LoggerSwitch', array('loggerId'=>$loggerId, 'field'=>'enabled', 'value'=>'0'))}")=' Yes'
          -else
            %a.color-red.icon-off(href="#{url('debug/LoggerSwitch', array('loggerId'=>$loggerId, 'field'=>'enabled', 'value'=>'1'))}")=' No'
        %td
          -$categories = is_string($route->categories) ? $route->categories : implode(',',$route->categories)
          =isEmpty($ategories) ? '*' : $categories
        %td
          -$levels = is_string($route->levels) ? $route->levels : implode(',',$route->levels)
          =isEmpty($levels) ? implode(',',array(CLogger::LEVEL_TRACE,CLogger::LEVEL_WARNING,CLogger::LEVEL_ERROR,CLogger::LEVEL_INFO,CLogger::LEVEL_PROFILE)) : $levels
        %td
          %table.table.table-condensed
            %thead
              %tr
                %th='Key'
                %th='Value'
            %tbody
              -foreach($props_keys as $prop)
                %tr
                  %td=$prop
                  %td=_2str($route->$prop)
        %td
          -if($runtimeLogger)
            %a(title="#{$loggerId}" href="#{url('debug/LoggerDelete',array('loggerId'=>$loggerId))}" onclick="return confirm('CONFIRM?');")
              .icon-trash

%hr

%h3
  ='Write log'
%form(method="get" action="#{url('debug/LoggersLog')}")
  %label#message_label(for="message_data")='Message:'
  %input#message_data(type="text" name="message" value="Fill me")

  %label#level_label(for="level_data")='Message:'
  %select#level_data(name="level")
    %option(value="info" selected="selected")='info'
    %option(value="trace")='trace'
    %option(value="profile")='profile'
    %option(value="warning")='warning'
    %option(value="error")='error'

  %label#category_label(for="category_data")='Message:'
  %input#category_data(type="text" name="category" value="custom.log")

  %br
  
  %input(type="submit")



