src/Entity/Log.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\LogRepository")
  6.  * @ORM\Table(name="log")
  7.  * @ORM\Table(indexes={
  8.  *                      @ORM\Index(name="IDX_LOG_LEVEL_NAME", columns={"level_name"}),
  9.  *                      @ORM\Index(name="IDX_LOG_SECTION", columns={"section"}),
  10.  *                      @ORM\Index(name="IDX_LOG_SOURCE", columns={"source"}),
  11.  *                      @ORM\Index(name="IDX_LOG_CONTEXT", columns={"context"}),
  12.  *                      @ORM\Index(name="IDX_LOG_CREATED_AT", columns={"created_at"}),
  13.  *                      @ORM\Index(name="IDX_LOG_TRIGGERED_BY", columns={"triggered_by"})
  14.  *                    })
  15.  * @ORM\HasLifecycleCallbacks
  16.  */
  17. class Log
  18. {
  19.     
  20.     const LOG_LVL_CRITICAL  = -2;
  21.     const LOG_LVL_ERROR        = -1;
  22.     const LOG_LVL_NOTICE    1;
  23.     const LOG_LVL_INFO        2;
  24.     const LOG_LVL_DEBUG        3;
  25.     
  26.     
  27.     const context = [
  28.         'USER' => [
  29.             'REGISTER',
  30.             'PAYMENT',
  31.         ],
  32.         'PREMIUM' => [
  33.             'REGISTER',
  34.             'EXTEND',
  35.             'UPGRADE',
  36.             'CANCEL',
  37.         ],
  38.     
  39.         'MAILCHIMP' => [
  40.             'REQUEST',
  41.             'RESPONSE'
  42.         ],
  43.         
  44.         'PNS' => [//Push Notification Service
  45.             'REQUEST',
  46.             'SQL'
  47.         ],
  48.     
  49.         'BROKER' => [
  50.             'MRK_REQUEST',
  51.             'MRK_RESPONSE',
  52.             'AVA_REQUEST',
  53.             'AVA_RESPONSE',
  54.             'CMT_REQUEST',
  55.             'AVA_RESPONSE',
  56.             'AVA_REQUEST_ROW',
  57.             'AVA_RESPONSE_ROW',
  58.             'AVA_REQUEST_EUR',
  59.             'AVA_RESPONSE_EUR',
  60.             'AVA_REQUEST_ROW_APP',
  61.             'AVA_RESPONSE_ROW_APP',
  62.             'AVA_REQUEST_EUR_APP',
  63.             'AVA_RESPONSE_EUR_APP'
  64.         ],
  65.         
  66.         'MARKETS_API' => [
  67.             'PRE_LEAD_REQUEST',
  68.             'PRE_LEAD_RESPONSE'
  69.         ]
  70.     ];
  71.     
  72.     const sections = ['user''premium''mailchimp''service''registration''api'];
  73.     
  74.     const sources = ['api''mobile''web''ios''android'];
  75.     
  76.     
  77.     /**
  78.      * @ORM\Id
  79.      * @ORM\Column(type="integer")
  80.      * @ORM\GeneratedValue(strategy="AUTO")
  81.      */
  82.     private $id;
  83.     /**
  84.      * @ORM\Column(name="message", type="text")
  85.      */
  86.     private $message;
  87.     /**
  88.      * @ORM\Column(name="context", type="string", length=100)
  89.      */
  90.     private $context;
  91.     /**
  92.      * @ORM\Column(name="level", type="smallint")
  93.      */
  94.     private $level;
  95.     /**
  96.      * @ORM\Column(name="level_name", type="string", length=50)
  97.      */
  98.     private $levelName;
  99.     /**
  100.      * @ORM\Column(name="section", type="string", length=50)
  101.      */
  102.     private $section;
  103.     /**
  104.      * @ORM\Column(name="source", type="string", length=50)
  105.      */
  106.     private $source;
  107.     
  108.     /**
  109.      * @ORM\Column(name="created_at", type="datetime")
  110.      */
  111.     private $createdAt;
  112.     /**
  113.      * @ORM\Column(name="triggered_by", type="string", length=255, nullable=true)
  114.      */
  115.     private $triggeredBy;
  116.     
  117.     public function getId(): ?int
  118.     {
  119.         return $this->id;
  120.     }
  121.     
  122.     public function validate(string $section): ?bool
  123.     {
  124.     return in_array($sectionself::sections);
  125.     }
  126.     public static function getSectionList(): ?array
  127.     {
  128.     return self::sections;
  129.     }
  130.     public static function getSourceList(): ?array
  131.     {
  132.     return self::sources;
  133.     }
  134.     
  135.     public static function getContextList(): ?array
  136.     {
  137.     return self::context;
  138.     }
  139.     public function getMessage(): ?string
  140.     {
  141.         return $this->message;
  142.     }
  143.     public function setMessage(string $message): self
  144.     {
  145.         $this->message $message;
  146.         return $this;
  147.     }
  148.     public function getContext(): ?string
  149.     {
  150.         return $this->context;
  151.     }
  152.     public function setContext(string $context): self
  153.     {
  154.         $this->context $context;
  155.         return $this;
  156.     }
  157.     public function getLevel(): ?int
  158.     {
  159.         return $this->level;
  160.     }
  161.     public function setLevel(int $level): self
  162.     {
  163.         $this->level $level;
  164.         return $this;
  165.     }
  166.     public function getLevelName(): ?string
  167.     {
  168.         return $this->levelName;
  169.     }
  170.     public function setLevelName(string $levelName): self
  171.     {
  172.         $this->levelName $levelName;
  173.         return $this;
  174.     }
  175.     public function getSection(): ?string
  176.     {
  177.         return $this->section;
  178.     }
  179.     public function setSection(string $section): self
  180.     {
  181.         $this->section $section;
  182.         return $this;
  183.     }
  184.     public function getSource(): ?string
  185.     {
  186.         return $this->source;
  187.     }
  188.     public function setSource(string $source): self
  189.     {
  190.         $this->source $source;
  191.         return $this;
  192.     }
  193.     
  194.     /**
  195.      * @ORM\PrePersist
  196.      */
  197.     public function onPrePersist()
  198.     {
  199.         $this->createdAt = new \DateTime();
  200.     }
  201.     public function getCreatedAt(): ?\DateTimeInterface
  202.     {
  203.         return $this->createdAt;
  204.     }
  205.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  206.     {
  207.         $this->createdAt $createdAt;
  208.         return $this;
  209.     }
  210.     
  211.     public function getTriggeredBy(): ?string
  212.     {
  213.         return $this->triggeredBy;
  214.     }
  215.     public function setTriggeredBy(string $triggeredBy): self
  216.     {
  217.         $this->triggeredBy $triggeredBy;
  218.         return $this;
  219.     }
  220.     
  221. }