in logging, you can set the size of the log file, as well as the number of backups.So where does the log path and capacity configuration fit? Let the user directly modify the parameters of the Rotatingfilehandler is not good, it is best not to let the user modify the framework file, the user simply call the interface to write their own script.The scenario used here is to write the configuration information to a file that the XML file is more appropriate to use as a configuration file, the user
PHP//PHP Design mode Observer Pattern /** The person being observed*/ classUserImplementssplsubject{ Public $lognum; Public $hobby; protected $observers=NULL; Public function__construct ($hobby){ $this->lognum=Rand(1,10); $this->hobby=$hobby; $this->observers=NewSplobjectstorage (); } Public functionLogin () {$this-notify (); } Public functionAttach (
Tag statistics is the number of labels that count,
1, modify the site statistics in the include/lib/cache.php file, add tag statistics cache. It's about 126-147 lines.
The code is as follows
Copy Code
Private Function Mc_sta () {$sta _cache = Array ();$lognum = $this->db->num_rows ($this->db->query (select Gid from). Db_prefix. "Blog WHERE type= ' blog ' and hide= ' n '"));$draftnum = $this->db->num_rows ($this->db->query
, and framework business is not coupled.
With the above analysis, we will implement the log module.
Because the log function is also part of the Framework Foundation, we put the log module in Common this package , Common under the new log.py file, the code is as follows:
# coding:utf-8from lxml import etreeimport logging.handlersimport loggingimport osimport sys# provides logging function class logger: # Read X First The configuration data in the ML file # because CONFIG. xml is placed in the s
with the framework business.
With the above analysis, we can implement the Log Module.
Because the log function is also part of the framework, we also put the Log Module inCommonThispackageInCommonCreatelog.pyFile, the Code is as follows:
# Coding: utf-8from lxml import etreeimport logging. handlersimport loggingimport osimport sys # provides the log function class logger: # Read the configuration data in the XML file first # Because of config. xml is placed in the same directory as the current
In the recent project, we need to generate n unequal random numbers. when implementing this, we can catch up with the construction period. In the project, n is very small (0-100). Thanks to the most intuitive method: Public static list As long as it is based on the return and return weights of the hashset to reach an unequal random number, but when num is large or num is close to threshold, at this time, the average expectation is relatively large. The complexity of num * threshold *
1. Add GridView to the page, modify the control name Gvuser
2. Set Data source DataSource (ObjectDataSource, etc.)
3. Set the DataKeyNames property of the GridView, delete operation is to follow this primary key to delete
4. Modify the code of the GridView, add modify to the inside, delete the button
autogeneratecolumns= "False" datakeynames= "UserId"Datasourceid= "Objectdatasourceuser" onrowdeleted= "gvuser_rowdeleted" >sortexpression= "UserId"/>sortexpression= "UserName"/>sortexpression= "Use
defined log class that uses the Logservice object to invoke the logbll. Add (log log) method to add a log message to the database.
123456789
public class Log {private Long id;private String logNum;private String userId;private Calendar time;private int type;private String content;...}
Step Two:write a inherit fromAppenderskeleton class, and overrides its Append method. In the Append method, the Java interface defined in the
1. Add the gridview to the page and modify the control name gvuser.
2. Set the data source datasource (objectdatasource, etc)
3. Set the datakeynames attribute of the gridview,The delete operation is based on this primary key.
4. modify the code of the gridview and add the modify and delete buttons to it.
Autogeneratecolumns = "false" datakeynames = "userid"Performanceid = "objectperformanceuser" onrowdeleted = "gvuser_rowdeleted">Sortexpression = "userid"/>Sortexpression = "username"/>Sortexpr
WebService or something, here is a Java interface.
Log is a defined Log class. You can use the LogService object to call the logBll. add (log Log) method to add a Log to the database.
123456789
public class Log {private Long id;private String logNum;private String userId;private Calendar time;private int type;private String content;...}
Step 2: compile a class that inherits the AppenderSkeleton class and override its append method.
Wanghan//usr/local/sa/agent/log, prefix sap1002, lognum, LogSize, loglevel 2[[Email protected]_ 168_102_centos tmp]# CP test_1.sh Wanghan/test.shcp:overwrite ' Wanghan/test.sh '? Y[[email Protected]_168_102_centos tmp]# cat wanghan/test.sh123Description: If the target exists and is a directory, copy the file to the destination directory and keep the original [Email protected]_168_102_centos tmp]# CP test_1.sh wanghan/[[email protected]_168_102_centos
Do not modify the kernel to achieve Emlog page page , the next page effect
1, first in the template you use the module.php file to add custom pagination function, the code is as follows:
code is as follows
copy code
//blog: Custom paging function function my_page ($count, $perlogs, $page, $url, $anchor = ') { $pnums = @ceil ($count /$perlogs); $re = '; $urlHome = preg_replace ("|[?") /][^./?=]*page[=/-]| "," ", $url); if ($page > 1) { $i = $page-1; $
(log log) method to add a log message to the database.
public class Log {
private Long ID;
Private String Lognum;
Private String userId;
Private Calendar time;
private int type;
Private String content;
...
}
Step Two:
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/
Write a class that inherits from the Appenderskeleton class and rewrite its Append method. In the Append method, you
log class that uses the Logservice object to invoke the logbll. Add (log log) method to add a log message to the database.
1 2 3 4 5 6 7 8 9
public class Log { private Long id; private String logNum; private String userId; private Calendar time; private int type; private String content; ... }
Step Two:write a inherit fromAppenderskeleton class, and overrides its Append method. In the Append method, the Java interface de
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.