Server IP : 180.180.241.3 / Your IP : 216.73.216.252 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files (x86)/MySQL/MySQL Workbench 6.1 CE/modules/ |
Upload File : |
,2Sc @ s d Z d d l m Z m Z m Z m Z m Z d d l Z d d l m Z m Z d d l m Z m Z m Z m Z m Z d d l Z d d l m Z m Z m Z m Z m Z d d l m Z d d l m Z m Z d e j f d YZ d e j f d YZ d S( s How to handle MySQL logs ************************* Among other things this module needs to establish: 1. Which of the logs (if any) are enabled. 2. Whether the output of the enabled logs are stored in a table or in a log file. Determining the state of the logs ----------------------------------- There are two possible scenarios: the server is down: In this case all logs are assumed to be **disabled** since the server won't be logging anything unless it's running. the server is up: Starting with MySQL Server 5.1.29 the relevant server variables changed. This derives in two new scenarios: server version < 5.1.29: :general query log: The state of this log is reflected in the server variable ``log`` which will be set to ``'OFF'`` if the log is disabled or to either ``'ON'`` or to ``'1'`` or to a file path if the log is enabled. :slow query log: Its state is reflected in the server variable ``log_slow_queries`` which will be set to ``'OFF'`` if the log is disabled or to ``'ON'`` or to ``'1'`` if the log is enabled. :error log: Its state is reflected in the server variable ``log_error`` which will be set to ``''`` (the empty string) if the log is disabled or to the path to the error log file if the log is enabled. .. note:: The error logs are not going to be written to the error log file if the server was started with the ``--console`` command line option on Windows, even if ``log_error`` has a path set up. In this case error logs are written to stderr. It seems that there's no way to query the server to determine if this ``--console`` option is in place. .. note:: The ``log_slow_queries`` and ``log`` variable were removed in MySQL Server 5.6. server version >= 5.1.29: :general query log: If enabled the ``general_log`` variable will be set to ``'ON'`` or to ``'1'``. Otherwise it will be set to ``'OFF'`` or to ``'0'``. :slow query log: If enabled the ``slow_query_log`` variable will be set to ``'ON'`` or to ``'1'``. Otherwise it will be set to ``'OFF'`` or to ``'0'``. :error log: Its state is reflected in the server variable ``log_error`` as explained for server version < 5.1.29. .. note:: For MySQL Server versions >= 5.1.6, if the variable ``log_output`` contains the value ``'NONE'``, the general query log and the slow query log will not record any new log entry. The general log can also be disabled by setting to ``'1'`` the session variable ``sql_log_off``. Determining where the logs are being written --------------------------------------------- Starting from MySQL Server 5.1.6 there's the possibility of sending the logs from the general query log or from the slow query log to a server table instead of to a log file. This is controlled by the value of the variable ``log_output`` which can be a combination of the values ``'FILE'`` (log into log files), ``'TABLE'`` (log into a server table) or ``'NONE'`` (don't log). If given, ``'NONE'`` takes precedence over the other values. .. warning:: For MySQL Server versions older than 5.1.29 there's no reliable way to know where the general and slow query logs are being written (if they are logged to a file). Their default values are ``$datadir + $hostname + '.log'`` and ``$datadir + $hostname + '-slow.log'``, respectively. This can be changed in the command line or in the configuration file and the real paths will not be exposed in any server variable. Starting from MySQL Server 5.1.29 the paths to the general and slow query log files are stored in the ``general_query_log_file`` and in the``slow_query_log_file`` variables, respectively. *The server creates the file in the data directory unless an absolute path name is given to specify a different directory.* Use cases for the server logs --------------------------------- 1. The server is running. All logs are enabled and WB can precisely determine their sources. Every log is shown in its corresponding tab. 2. The ``log_output`` server variable contains both ``'FILE'`` and ``'TABLE'``. WB will select on a per log basis which source should be chosen. Will select table logs if the server is local or if the server is remote and any of these happen: * Cannot reliably determine the paths to the log file. * The user running WB has no read permissions on the log file. * The log file does not exist. * The user explicitly requested to read from log table. 3. ``log_output`` contains ``'NONE'``. Nonetheless WB will check for log sources and will show them, alerting the user about log not being updated because of that. *What to do if there are log files and log tables available in this case?* 4. The server is logging to files and WB can precisely determine their paths but the log file is missing in the file system. The situation will be reported to the user (advising him to ``FLUSH LOGS`` or restart the server and start querying) The log will not be shown as long as this situation persists. 5. The server is logging to tables and the connection to the server is lost. If the server is also logging to files, and a log file exists in the file system, the log file will be shown and the user will be warned about this change. 6. The server is logging to files and WB cannot precisely determine the path to the log file (i.e. server version < 5.1.29). WB will try to get the path from these sources in this order: 1. The server's configuration file. 2. The default path assumed by the server when no log path is specified. If no such file is found in the file system the log will not be shown. 7. The user changed the source of a log or the path to a log file while WB was showing the previous source/path. WB will switch to the new source/path and will inform the user of the change. 8. [Postponed] The user clicks on a *Add new log* button. A dialog will be shown in which the user will select the type of log to be added (error, general or slow), the log source (a database table or a log file) and the name of the log table/file. A new tab showing the user selected log will be shown and will persist during the session or until the user clicks on the tab's *Close* button. i( t newBoxt newLabelt newTreeNodeViewt newTabViewt newButtonN( t not_running_warning_labelt make_panel_header( t GeneralQueryLogReadert SlowQueryLogReadert GeneralLogFileReadert SlowLogFileReadert ErrorLogFileReader( t LogFileAccessErrort ServerIOErrort OperationCancelledErrort InvalidPasswordErrort log_error_decorator( t WorkerThreadHelper( t log_errort log_debugt LogViewc B s e Z d Z d Z e d Z d Z d Z d Z d d Z d Z d Z d Z d Z d Z d Z RS( s| Main front end view class for displaying log entries. Each page in the Tab View is an instance of this class. c G s t t | j t | j | j | | _ | | _ | | _ d | _ d | _ d | _ d | _ d | _ | j d | _ d S( s The arguments following BackendLogReaderClass will be passed to BackendLogReaderClass to instantiate it in order to get a log reader object. N( t superR t __init__t Falset set_managedt set_release_on_addt ownert BackendLogReaderClasst argst Nonet log_readert error_boxt treet bboxt warning_boxt update_uit worker( t selfR R R ( ( sL C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_admin_logs.pyR s c C s | j r% | j | j d | _ n t t | _ | j j d t t | } | j j | t t t } | j d | j j | t t | j | j | j | j t t d S( Ni s Try again( R t removeR R t Truet set_spacingR t strt addR R t set_textt add_clicked_callbackR# ( R% t errort error_labelt try_again_button( ( sL C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_admin_logs.pyt _show_error s c C s | j r% | j | j d | _ n | j rJ | j | j d | _ n | j ro | j | j d | _ n | j r | j | j d | _ n | j d | j d y | j | j | _ WnA t t t t t t f k r } t d | | j | d SX| j j rwt t | _ | j j d t | j j } | j j | t t | j | j t t n t t j | _ | j j t j x8 | j j D]* } | j j t j | d | d t qW| j j! | j | j t t t j"