Monologã®fingers_crossedãããããããã£ã
Monologã¯Symfony2ã§ãå©ç¨ããã¦ããé«æ©è½ãªãã¬ã¼ã©ã¤ãã©ãªã§ããPythonã®Logbookã¨ããã©ã¤ãã©ãªãPHPã«ç§»æ¤ãããã®ã ã¨è¨æ¶ãã¦ãã¾ãã
Symfony2ã® app/config/config_dev.yml ã§ã¯ãMonologã¯æ¬¡ã®ããã«è¨å®ããã¦ãã¾ãã
monolog: handlers: main: type: stream path: %kernel.logs_dir%/%kernel.environment%.log level: debug
ããã¯ãã®ã¾ã¾ãdebug以ä¸ã®ã¬ãã«ã®ãã°ãpathã«æå®ãããã°ãã¡ã¤ã«ã«æ¸ãåºãã¨ããæå®ã§ããconfig_dev.phpãªã®ã§éçºç°å¢ç¨ã®è¨å®ãã¡ã¤ã«ã§ããããã°ã¯ãã¹ã¦æ¸ãåºãã¨ããè¨å®ã§ãã
ããã¨ã¯å¥ã«ãéç¨ç°å¢ç¨ã® config_prod.yml ã§ã¯æ¬¡ã®ããã«è¨å®ããã¦ãã¾ãã
monolog: handlers: main: type: fingers_crossed action_level: error handler: nested nested: type: stream path: %kernel.logs_dir%/%kernel.environment%.log level: debug
nestedã¨ããé¨åã¯config_dev.ymlã®ãã®ã¨åä¸ã§ããããã¨ã¯å¥ã«ãfingers_crossedã¨ãããtypeã®ãã³ãã©ã¼ãè¨å®ããã¦ãã¾ããä»ã¾ã§ãã®fingers_crossedã¨ããã®ãä½ãããããããªãã£ãã®ã§èª¿ã¹ã¦ã¿ã¾ããã
ä¸è¨ã®config_prod.ymlã®è¨å®ã ã¨ã©ã®ããã«ãªããã¨ããã¨ããã°ã¬ãã«ãerror以ä¸ã®ãã°ãè¨é²ãããå ´åã®ã¿ãã°ãåºåãããããã®ã¨ãã¯ããã¾ã§ã«è¨é²ãããdebug以ä¸ã®ãã¹ã¦ã®ãã°ãåºåããã¾ãã
FingersCrossedHandler: A very interesting wrapper. It takes a logger as parameter and will accumulate log records of all levels until a record exceeds the defined severity level. At which point it delivers all records, including those of lower severity, to the handler it wraps. This means that until an error actually happens you will not see anything in your logs, but when it happens you will have the full information, including debug and info records. This provides you with all the information you need, but only when you need it.
GitHub - Seldaek/monolog: Sends your logs to files, sockets, inboxes, databases and various web services
å¾æ¥ã®ãã¬ã¼ã§ã¯ãerror以ä¸ã¨è¨å®ããå ´åãerror以ä¸ã®ãã°ã®ã¿ãè¨é²ããã¾ããããããã¨ã©ã¼ãåºãå ´åã¯ãã詳細ãªãã°ãã¿ããã¨ãããã®ã§ãããã®fingers_crossedãç¨ããã¨ãã¨ã©ã¼ããã£ãããã»ã¹ã¯ãããã°æ å ±ãå«ãããã°ãæ®ããããã¨ã©ã¼ã®è¿½æ±ãªã©ã容æã«ãªãã¾ãã
ä»ã¾ã§ã¯éç¨ç°å¢ã§ã¯ãããã°ãã°ãªããã¯åºåããªãããã«ãã¦ãã¾ããããããã§ããã°ãæ®ãããã«è¨å®ãã¦ããã¦æã¯ãªããªã¨æãã¾ããã