教朋友们用代码做一幅漂亮的日志

合集下载

日志信纸代码

日志信纸代码

日志信纸代码日志信纸代码一、稿纸型信纸代码如下:<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD><SPAN id=c_107086><CENTER><TABLE cellSpacing=0 cellPadding=0 width="95%" border=0><TBODY><TR><TD width=66 height=26><IMG src=" /><TD background= height=26> </TD><TD width=26 height=26><IMG src=" /><TR><TD width=66 background= /><TD><CENTER><TABLE width="100%" background= /><TBODY><TR><TD><BR><P align=left><FONT face=宋体color=#5b005b size=2><FONT face=隶书 size=5></FONT><BR><BR></FONT> <P></P><FONT face=宋体color=#5b005b size=2></FONT><BR></TD></TR></TBODY></TABLE></CE NTER></TD><TD width=26 background= </TD></TR><TR><TD width=66 height=31><IMG src=" /><TD background= height=31> </TD><TD width=26 height=31><IMG src="二、星空型纸信代码如下:<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD><SPAN id=c_107084><TABLE cellSpacing=1 cellPadding=0 width="98%" align=center border=0><TBODY><TR><TD></TD></TR><TR><TD height=17><TABLE height='’border="0"’' cellSpacing=0 cellPadding=0 width="90%"><TBODY><TR><TD width=300 bgColor=#283b97 height=120> </TD><TD background= /><TD width=253 background= height=120> </TD></TR></TBODY></TABLE><TABLE cellSpacing=0 cellPadding=0 width="90%" border=0><TBODY><TR><TD width=22 bgColor=#283b97> </TD><TD style="PADDING-BOTTOM: 30px; COLOR: #aed4ee; LINE-HEIGHT: 28px" background=/><DIV><STATIONERY> <STATIONERY></DIV></TD> <TD width=18 bgColor=#283b97> </TD></TR></TBODY></TABLE> <TABLE cellSpacing=0 cellPadding=0 width="90%"><TBODY><TR><TD vAlign=bottom width=116 background= bgColor=#ffffff height=120> </TD><TD style="FONT-SIZE: 12px; COLOR: #79b4c5" vAlign=bottom align=right background=三、紫花黑底信纸代码如下:<TABLE cellPadding=50 width=480 align=center background= border=0 cellSpacing30><TBODY><TR><TD><TABLE borderColor=#ffffff cellSpacing=5 borderColorDark=#9966ff cellPadding=0 width=380 align=center border=3><TBODY><TR><TD><BR><P align=center><FONT face=仿宋color=#9966ff size=4></FONT><CENTER></CENTER><P></P></TD></TR></TBODY></TABLE></TD></TR></ TBODY></TABLE>四、蓝宝石信纸代码如下:<P><TABLE style="WIDTH: 442px; HEIGHT: 119px" borderColor=#0091ff height=119 cellSpacing=2 cellPadding=32width=442 align=center background= border=1><TBODY><TR><TD><CENTER><P align=center><FONT style="FONT-WEIGHT: normal; FONT-SIZE: 18pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal" face=隶书color=#ff9a00> </P></FONT><BR><BR><P></P><IMG style="BORDER-LEFT-COLOR: #000000; BORDER-BOTTOM-COLOR: #000000; WIDTH: 402px; BORDER-TOP-COLOR: #000000; HEIGHT: 40px; BORDER-RIGHT-COLOR: #000000" height=64 src=" width=402 border=0><BR></FONT></CENTER></TD></TR></TBODY> </TABLE></P>五、苹果树下信纸代码如下:<P><TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0><TBODY><TR></TR><TR></TR><TR><TD id=msgcns!1pSt_gP1XO9shQaTTwgpJy7Q!8893><TABLE cellSpacing=0 cellPadding=0 width="99%" align=center border=0><TBODY><TR><TD width=178 background= height=114> </TD><TD width=205 background= /><TD background= /><TABLE width="99%" align=center bgColor=#eff0e2border=0><TBODY><TR><TD width=60> </TD><TD background= /><DIV style="FONT-SIZE: 11pt; COLOR: #666666; LINE-HEIGHT: 34px; TEXT-ALIGN: left"><DIV style="FONT-SIZE: 11pt; COLOR: #666666; LINE-HEIGHT: 25px; TEXT-ALIGN: left"> </DIV><DIV style="FONT-SIZE: 11pt; COLOR: #666666; LINE-HEIGHT: 25px; TEXT-ALIGN: left"> </DIV></DIV></TD> <TD width=60> </TD></TR></TBODY></TABLE><TABLE cellSpacing=0 cellPadding=0 width="99%" align=center bgColor=#eff0e2 border=0><TBODY><TR><TD background=六、红叶落下信纸代码如下:<P><TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0><TBODY><TR></TR><TR></TR><TR><TD id=msgcns!1pSt_gP1XO9shQaTTwgpJy7Q!8891><TABLE height=88 cellSpacing=0 cellPadding=0 width="99%" bgColor=#ffffff border=0><TBODY><TR><TD width=100 background= /><TD style="BACKGROUND-POSITION: 50% bottom; BACKGROUND-REPEAT: repeat-x"background= /><TD style="BACKGROUND-POSITION: 0% 0%; BACKGROUND-REPEAT: no-repeat" width=35 background= bgColor=#a88766> </TD></TR></TBODY></TABLE> <TABLE cellSpacing=0 cellPadding=0 width="99%" bgColor=#a88766 border=0><TBODY><TR><TD style="BACKGROUND-POSITION: right 50%; BACKGROUND-REPEAT: repeat-y" width=33 background= /><TD background= /><TABLE style="COLOR: #333333" width="90%" background= border=0><TBODY><TR><TD style="LINE-HEIGHT: 30px"><DIV>正文稿</DIV></TD></TR></TBODY></TABLE></TD><TD style="BACKGROUND-POSITION: left 50%; BACKGROUND-REPEAT: repeat-y" width=30 background=七、休闲咖啡信纸代码如下:<P><TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0><TBODY><TR></TR><TR></TR><TR><TD id=msgcns!1pSt_gP1XO9shQaTTwgpJy7Q!8881><TABLE cellSpacing=0 cellPadding=0 width="99%" align=center bgColor=#fff4e1 border=0><TBODY><TR bgColor=#feebc7><TD align=left rowSpan=2><IMG style="CURSOR: pointer" src=" width=144 onload="javascript:if( onclick=" javascript:();?></TD><TD vAlign=bottom align=right bgColor=#feebc7 height=77><IMG style="CURSOR: pointer" src=" width=356 onload="javascript:if( onclick=" javascript:();?></TD></TR> <TR><TD align=right bgColor=#feebc7 height=57><IMG style="CURSOR: pointer" src=" width=391 onload="javascript:if( onclick=" javascript:();?></TD></TR> <TR><TD colSpan=2><BR><TABLE width="85%" align=center border=0><TBODY><TR><TD><DIV style="FONT-SIZE: 11pt; COLOR: #79452f; LINE-HEIGHT: 25px; TEXT-ALIGN: left"><DIV><P><FONT face=楷体_GB2312 size=5></FONT> </P></DIV></DIV></TD></TR></TBODY> </TABLE></TD></TR><TR><TD align=left><IMG style="CURSOR: pointer" src=" width=96 onload="javascript:if( onclick=" javascript:();?> <TD><TABLE cellSpacing=0 border=0><TBODY></TBODY></TABLE></TD></TR></TBODY></T ABLE><SPAN style="FONT-SIZE: 10pt"></SPAN><P></P><BR></TD></TR></TBODY></TABLE></P>代码使用方法:1、打开撰写新日志窗口,勾选“显示源代码”,将上面的代码复制后粘贴于撰写栏内;2、取消“显示源代码”前方框内的对号,即可直接直接在撰写栏内所显示的信纸上撰写并排版日志内容。

日记 php 源码

日记 php 源码

以下是一个简单的PHP 日记源码示例:```php<?phpclass Diary {private $entries;public function __construct() {$this->entries = array();}public function addEntry($title, $content) {$entry = array('title' => $title,'content' => $content,'timestamp' => date('Y-m-d H:i:s'));$this->entries[] = $entry;}public function getEntries() {return $this->entries;}}$diary = new Diary();$diary->addEntry('今天天气很好', '今天阳光明媚,适合出去玩。

');$diary->addEntry('学习PHP', '今天学习了PHP 的基本语法和常用函数。

');foreach ($diary->getEntries() as $entry) {echo '标题:' . $entry['title'] . PHP_EOL;echo '内容:' . $entry['content'] . PHP_EOL;echo '时间:' . $entry['timestamp'] . PHP_EOL;echo PHP_EOL;}>```这个示例中,我们定义了一个名为`Diary` 的类,它包含一个用于存储日记条目的数组。

恋爱日记源码范文

恋爱日记源码范文

恋爱日记源码范文下面是一个简单的恋爱日记的源码,包括了用户输入和保存的功能。

源码使用Python编写,具体细节如下:```pythondef create_diary_entry(:"""创建一条恋爱日记记录"""content = input("请输入今天的恋爱日记内容:")entry = f"{date}\n{content}\n" # 拼接日期和内容return entrydef save_diary_entry(entry):"""保存恋爱日记记录到文件"""with open("love_diary.txt", "a") as f:f.write(entry)print("日记已保存成功!")def view_diary_entries(:"""查看已保存的恋爱日记记录"""with open("love_diary.txt", "r") as f:entries = f.readlinesif entries:print("已保存的日记记录:")for entry in entries:print(entry)else:print("暂无日记记录!")def main(:"""主函数,控制日记的创建和查看操作"""print("欢迎使用恋爱日记程序!")while True:print("\n请选择操作:")print("1. 写入新的日记")print("2. 查看已保存的日记")print("3. 退出程序")choice = input("请选择操作编号(1/2/3):") if choice == "1":entry = create_diary_entrysave_diary_entry(entry)elif choice == "2":view_diary_entrieselif choice == "3":print("谢谢使用breakelse:print("无效的选择!请重新输入!")#调用主函数if __name__ == "__main__":main```这个源码实现了一个简单的恋爱日记程序,用户可以选择写入新的日记记录或查看已保存的日记记录。

精美日历的程序设计及代码示例

精美日历的程序设计及代码示例

精美日历的程序设计及代码示例一、引言日历是我们日常生活中重要的时间管理工具。

一个精美美观的日历设计可以提升用户的使用体验。

本文将介绍精美日历的程序设计方法以及相应的代码示例。

二、设计思路1. 日历显示界面设计精美日历应该具备以下设计要素:- 界面简洁明了,突出重要信息;- 适配不同设备屏幕尺寸,保证用户在不同设备上都能良好显示;- 使用合适的字体、颜色和布局,营造舒适的阅读体验;- 支持用户自定义主题,以满足不同用户的个性化需求。

2. 日历功能设计精美日历的功能设计要考虑以下几点:- 显示当前日期以及所在月份,方便用户快速查看;- 支持切换月份,以便查看过去或未来的日期;- 标记重要日期,例如节假日、生日等,以便用户一目了然;- 提供日程管理功能,允许用户添加、编辑和删除日程安排;- 支持农历显示,满足中国用户的需求。

三、代码示例下面是一个简单的精美日历的代码示例,代码使用HTML、CSS和JavaScript编写。

```<!DOCTYPE html><html><head><title>精美日历</title><style>/* CSS样式 *//* 省略部分样式代码,包括字体、颜色和布局等 */</style></head><body><div id="calendar"><div id="header"><button id="prevBtn">上个月</button><div id="title"></div><button id="nextBtn">下个月</button> </div><table id="days"><tr><th>周一</th><th>周二</th><th>周三</th><th>周四</th><th>周五</th><th>周六</th><th>周日</th></tr><!-- 日期格子动态生成 --></table></div><script>// JavaScript代码// 获取当前日期var date = new Date();var currentYear = date.getFullYear();var currentMonth = date.getMonth() + 1;// 标记重要日期var importantDates = [5, 10, 15];// 更新日历显示function updateCalendar(year, month) {// 更新标题document.getElementById("title").innerHTML = year + "年" + month + "月";// 清空日期格子var table = document.getElementById("days");table.getElementsByTagName("tbody")[0].innerHTML = "";// 获取本月第一天的日期对象var firstDay = new Date(year, month - 1, 1);var startDay = firstDay.getDay(); // 本月第一天是星期几// 动态生成日期格子var dateIndex = 1;var tr = document.createElement("tr");for (var i = 0; i < startDay; i++) {tr.innerHTML += "<td></td>";}while (firstDay.getMonth() === month - 1) {if (startDay === 0) {table.getElementsByTagName("tbody")[0].appendChild(tr); tr = document.createElement("tr");}var td = document.createElement("td");td.innerHTML = dateIndex;if (importantDates.includes(dateIndex)) {td.classList.add("important"); // 添加重要日期样式}tr.appendChild(td);dateIndex++;firstDay.setDate(firstDay.getDate() + 1);startDay = firstDay.getDay();}table.getElementsByTagName("tbody")[0].appendChild(tr);}// 切换月份document.getElementById("prevBtn").addEventListener("click", function() {if (currentMonth === 1) {currentYear--;currentMonth = 12;} else {currentMonth--;}updateCalendar(currentYear, currentMonth);});document.getElementById("nextBtn").addEventListener("click", function() {if (currentMonth === 12) {currentYear++;currentMonth = 1;} else {currentMonth++;}updateCalendar(currentYear, currentMonth);});// 初始化日历updateCalendar(currentYear, currentMonth);</script></body></html>```四、总结本文介绍了精美日历的程序设计方法及相应的代码示例。

C++实现一个日志类

C++实现一个日志类

C++实现⼀个⽇志类转载:我们可能遇到发包后,在客户机器上出现各种未知错误,如果没有⽇志打印,对于问题解决是很困难的,因此常规的解决办法就是打印⽇志。

在此⽤C++ 实现⼀个简单的⽇志类,使⽤cout输出调试信息,同时把⽇志写到⽂件中,实现了⼀个Logger类,主要考虑实现以下功能:⽇志等级: 参考python的logger类,我设置了四个⽇志等级, 从低到⾼依次为debug, info, warning, error,这样的话我想输出⼀条debug 信息就可以这样写logger.debug("something..."), (关于⽇志等级是什么意思可以参考⼀下python的logger类,简单来说就是当⽇志等级⼤于等于设置的初始等级时才会记录⽇志)输出⽬标: 我设置了三种输出⽬标: 仅输出到终端、仅输出到⽂件、既输出到终端⼜输出到⽂件为了⽅便的设置⽇志等级,可以⽤⼀个枚举类表⽰四种⽇志等级,同理⽤⼀个枚举类表⽰三种输出⽬标enum log_level{debug, info, warning, error};// ⽇志等级enum log_target{file, terminal, file_and_terminal};// ⽇志输出⽬标Logger.h#ifndef _LOGGER_H_#define _LOGGER_H_#include <iostream>#include <fstream>#include <time.h>#pragma warning (disable:4996)class Logger{public:enum log_level { debug, info, warning, error };// ⽇志等级enum log_target { file, terminal, file_and_terminal };// ⽇志输出⽬标public:Logger();Logger(log_target target, log_level level, const std::string& path);~Logger();void DEBUG(const std::string& text);void INFO(const std::string& text);void WARNING(const std::string& text);void ERRORS(const std::string& text);private:std::ofstream m_outfile; // 将⽇志输出到⽂件的流对象log_target m_target; // ⽇志输出⽬标std::string m_path; // ⽇志⽂件路径log_level m_level; // ⽇志等级void output(const std::string &text, log_level act_level); // 输出⾏为};#endif//_LOGGER_H_Logger.cpp#include "Logger.h"#include <string>std::string currTime(){// 获取当前时间,并规范表⽰char tmp[64];time_t ptime;time(&ptime); // time_t time (time_t* timer);strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&ptime));return tmp;}Logger::Logger(){// 默认构造函数m_target = terminal;m_level = debug;std::cout << /*"[WELCOME] " << __FILE__ << " " <<*/ currTime() << " : " << "=== Start logging ===" << std::endl;}Logger::Logger(log_target target, log_level level, const std::string& path){m_target = target;m_path = path;m_level = level;std::string strContent = currTime() + " : " + "=== Start logging ===\n"; if (target != terminal) {m_outfile.open(path, std::ios::out | std::ios::app); // 打开输出⽂件 m_outfile << strContent;}if (target != file){// 如果⽇志对象不是仅⽂件std::cout << strContent;}}Logger::~Logger(){std::string strContent = currTime() + " : " + "=== End logging ===\r\n"; if (m_outfile.is_open()){m_outfile << strContent;}m_outfile.flush();m_outfile.close();}void Logger::DEBUG(const std::string& text){output(text, debug);}void Logger::INFO(const std::string& text){output(text, info);}void Logger::WARNING(const std::string& text){output(text, warning);}void Logger::ERRORS(const std::string& text){output(text, error);}void Logger::output(const std::string &text, log_level act_level){std::string prefix;if (act_level == debug) prefix = "[DEBUG] ";else if (act_level == info) prefix = "[INFO] ";else if (act_level == warning) prefix = "[WARNING] ";else if (act_level == error) prefix = "[ERROR] ";//else prefix = "";//prefix += __FILE__;//prefix += " ";std::string outputContent = prefix + currTime() + " : " + text + "\n";if (m_level <= act_level && m_target != file){// 当前等级设定的等级才会显⽰在终端,且不能是只⽂件模式std::cout << outputContent;}if (m_target != terminal)m_outfile << outputContent;m_outfile.flush();//刷新缓冲区}测试#include "Logger.h"void test() {Logger logger(Logger::file_and_terminal, Logger::debug, "Log.log");logger.DEBUG("Debug info");("This is variable");logger.WARNING("This function or variable may be unsafe");logger.ERRORS("Memory leak");}int main(){test();getchar(); return0; }。

利用python实现记录日志,附代码和优化

利用python实现记录日志,附代码和优化

利⽤python实现记录⽇志,附代码和优化⼤家肯定都见过⽇志,在⾃动化中加⼊⽇志信息,有助于问题的定位下⾯第⼀段代码实现基本的⽇志记录,第⼆段代码是进⾏优化过的⽇志模块__author__ = 'zz'import logging#定义⼀个属于⾃⼰的⽇志收集器from common import project_pathclass MyLog:def my_log(self,level,msg):my_logger=logging.getLogger("xxxx")my_logger.setLevel("DEBUG")#设置#创造⼀个专属输出渠道过滤和排版#格式:formatter = logging.Formatter('%(asctime)s-%(levelname)s-%(filename)s-%(name)s-⽇志信息:%(message)s')ch=logging.StreamHandler()#输出到控制台ch.setLevel("DEBUG")#设置输出级别⼤写ch.setFormatter(formatter)fh=logging.FileHandler(project_path.logs_path,encoding='UTF-8')#输出到制定⽂件fh.setLevel("DEBUG")#设置输出级别⼤写fh.setFormatter(formatter)#对接起来给⽇志收集器添加⼀个渠道my_logger.addHandler(ch)my_logger.addHandler(fh)if level=='DEBUG':my_logger.debug(msg)elif level=='INFO':my_(msg)elif level=='WARNING':my_logger.warning(msg)elif level=='ERROR':my_logger.error(msg)elif level=='CRITICAL':my_logger.critical(msg)# #渠道要记得移除掉否则⽇志输出会重复my_logger.removeHandler(ch)my_logger.removeHandler(fh)def debug(self,msg):self.my_log("DEBGU",msg)def info(self, msg):self.my_log("INFO",msg)def warning(self,msg):self.my_log("ERROR",msg)def error(self,msg):self.my_log("WARNING",msg)def critical(self,msg):self.my_log("CRITICAL",msg)if__name__ == '__main__':my_logger=MyLog()my_logger.debug(xxx)my_(xxx)my_logger.warning(xxx)my_logger.error(xxx)my_logger.critical(xxx)可优化部分:⽇志级别及输出⽂件写在配置⽂件中,可通过修改配置⽂件中的参数达到修改⽇志模块参数的效果class Logger(object):def__init__(self, logger_name='NGTP'):self.logger = logging.getLogger(logger_name)#定义⽇志收集器logging.root.setLevel(logging.NOTSET)if Config().get('LOG_FILENAME'): # ⽇志⽂件名称/读取config.json⽂件中的LOG_FILENAME值self.log_file_name = Config().get('LOG_FILENAME')else:self.log_file_name = 'test.log'if Config().get('LOG_BACKUP'): # /读取config.json⽂件中的LOG_BACKUP值self.backup_count = Config().get('LOG_BACKUP')else:self.backup_count = 5if Config().get('LOG_CONSOLE_LEVEL'): # 读取config.json⽂件中的LOG_CONSOLE_LEVEL值,控制台输出⽇志级别 self.console_output_level = Config().get('LOG_CONSOLE_LEVEL')else:self.console_output_level = 'INFO'if Config().get('LOG_FILE_LEVEL'): # 读取config.json⽂件中的LOG_FILE_LEVEL值,⽂件输出⽇志级别self.file_output_level = Config().get('LOG_FILE_LEVEL')else:self.file_output_level = 'DEBUG'if Config().get('LOG_PARTTERN'): # 读取config.json⽂件中的LOG_PARTTERN值,输出⽇志格式self.formatter = logging.Formatter(Config().get('LOG_PARTTERN'))else:self.formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')def get_logger(self):if not self.logger.handlers:console_handler = logging.StreamHandler()#定义⽇志输出到控制台console_handler.setFormatter(self.formatter)#控制台输出格式console_handler.setLevel(self.console_output_level)#控制台输出级别self.logger.addHandler(console_handler)#收集器和⽇志输出控制台加连接file_handler = TimedRotatingFileHandler(filename=os.path.join(LOG_PATH, self.log_file_name),when='D',interval=1,backupCount=self.backup_count,delay=True,encoding='utf-8')file_handler.setFormatter(self.formatter)file_handler.setLevel(self.file_output_level)self.logger.addHandler(file_handler) #收集器和⽇志输出到⽂件加连接return self.loggerlogger = Logger().get_logger()。

C#简单写日志

C#简单写日志

C#简单写⽇志public static string LogDirectory = GetDirectoryName(Assembly.GetAssembly(typeof(LogManager))) + "\\Log";//public static string LogDirectory = AppDomain.CurrentDomain.BaseDirectory + "Log\\";public static string GetAssemblyPath(Type type){return GetAssemblyPath(type.Assembly);}public static string GetDirectoryName(Assembly assembly){return Path.GetDirectoryName(GetAssemblyPath(assembly));}public static string GetAssemblyPath(Assembly assembly){string escapedCodeBase = assembly.EscapedCodeBase;if (IsFileUri(escapedCodeBase)){return GetAssemblyPathFromEscapedCodeBase(escapedCodeBase);}return assembly.Location;}public static string GetAssemblyPathFromEscapedCodeBase(string escapedCodeBase){return new Uri(escapedCodeBase).LocalPath;}private static bool IsFileUri(string uri){return uri.ToLower().StartsWith(Uri.UriSchemeFile);}///<summary>///保存的最多⽇志数量///</summary>private static int MaxLogCount = 365;///<summary>//////</summary>///<param name="msg"></param>///<param name="logfilename">⽇志⽂件名称</param>public static void Write(string msg, string logfilename = ""){try{DeleteLog();string datapath = GetLogFilePath(logfilename);if (System.IO.File.Exists(datapath))//追加{using (FileStream fs = new FileStream(datapath, FileMode.Append)){using (StreamWriter sw = new StreamWriter(fs)){//开始写⼊sw.WriteLine("\n");sw.WriteLine("当前时间:" + DateTime.Now.ToString());sw.WriteLine("⽇志信息:" + msg);//清空缓冲区sw.Flush();//关闭流sw.Close();fs.Close();}}}else//创建{using (FileStream fs = new FileStream(datapath, FileMode.Create)){using (StreamWriter sw = new StreamWriter(fs)){//开始写⼊sw.WriteLine("当前时间:" + DateTime.Now.ToString());sw.WriteLine("⽇志信息:" + msg);//清空缓冲区sw.Flush();//关闭流sw.Close();fs.Close();}}}}catch{}}public static void Write(Exception ex, string logfilename = ""){try{DeleteLog();string datapath = GetLogFilePath(logfilename);if (System.IO.File.Exists(datapath))//追加{using (FileStream fs = new FileStream(datapath, FileMode.Append)) {using (StreamWriter sw = new StreamWriter(fs)){ //开始写⼊sw.WriteLine("\n");sw.WriteLine("当前时间:" + DateTime.Now.ToString());sw.WriteLine("异常信息:" + ex.Message);sw.WriteLine("异常对象:" + ex.Source);sw.WriteLine("调⽤堆栈:" + ex.StackTrace);sw.WriteLine("消息:" + ex.InnerException.Message);sw.WriteLine("触发⽅法:" + ex.TargetSite);//清空缓冲区sw.Flush();//关闭流sw.Close();fs.Close();}}}else//创建{using (FileStream fs = new FileStream(datapath, FileMode.Create)) {using (StreamWriter sw = new StreamWriter(fs)){//开始写⼊sw.WriteLine("当前时间:" + DateTime.Now.ToString());sw.WriteLine("异常信息:" + ex.Message);sw.WriteLine("异常对象:" + ex.Source);sw.WriteLine("调⽤堆栈:" + ex.StackTrace);sw.WriteLine("消息:" + ex.InnerException.Message);sw.WriteLine("触发⽅法:" + ex.TargetSite);//清空缓冲区sw.Flush();//关闭流sw.Close();fs.Close();}}}}catch{}}public static void Write(object obj, string logfilename = ""){Write(obj.ToString());}///<summary>///获取⽇志存储路径///</summary>///<returns></returns>private static string GetLogFilePath(string logfilename){string filepath = "";if (!System.IO.Directory.Exists(LogDirectory)){System.IO.Directory.CreateDirectory(LogDirectory);}filepath = LogDirectory + DateTime.Now.ToString("yyyy-MM-dd") + "_" + logfilename + ".txt";return filepath;}///<summary>///删除多余⽇志///</summary>private static void DeleteLog(){DirectoryInfo dic = new DirectoryInfo(LogDirectory);//不必每天都删除⽇志,整10天删除if (!(DateTime.Now.Day % 10 == 0)){return;}if (dic.Exists){var files = dic.GetFiles();if (files.Length < MaxLogCount)return;List<int> names = new List<int>();for (int i = 0; i < files.Length; i++){string strname = Path.GetFileNameWithoutExtension(files[i].Name);int name;if (int.TryParse(strname, out name)){names.Add(name);}}names.Sort();//升序//names.Reverse();//降序for (int i = 0; i < names.Count - MaxLogCount; i++){string path = bine(LogDirectory, names[i].ToString() + ".txt");File.Delete(path);}}}。

代码工作日记

代码工作日记

代码工作日记Code Diary: A Record of My Daily Work。

As a software developer, I spend most of my time writing code and solving problems. To keep track of my progress and reflect on my work, I started keeping a code diary. In this diary, I record my daily tasks, challenges, and achievements. In this article, I will share my experience with keeping a code diary and how it has helped me improve my skills and productivity.Why Keep a Code Diary?A code diary is a record of your daily work as a programmer. It can be a simple text file, a notebook, or a digital tool like Evernote or OneNote. The purpose of keeping a code diary is to:1. Track your progress: By recording your daily tasks, you can see how much you have accomplished over time. Thiscan help you stay motivated and focused on your goals.2. Reflect on your work: By reviewing your diary regularly, you can identify patterns in your work and learn from your mistakes. This can help you improve your skills and avoid making the same mistakes in the future.3. Plan your next steps: By setting goals andpriorities in your diary, you can plan your work for the next day or week. This can help you stay organized and avoid procrastination.What to Include in Your Code Diary?Your code diary should include the following information:1. Date: Record the date of each entry.2. Tasks: Write down the tasks you worked on that day. Be specific and include details such as the project name, the feature you implemented, or the bug you fixed.3. Challenges: Describe any challenges you faced during your work. This can include technical difficulties, communication issues, or time constraints.4. Solutions: Explain how you solved the challenges you faced. This can help you remember what worked and whatdidn't, and can be useful for future reference.5. Achievements: Note any achievements or milestones you reached that day. This can include completing a task, learning a new skill, or receiving positive feedback from a colleague or client.6. Goals: Set goals for your next day or week. This can help you stay focused and motivated.How to Use Your Code Diary?To make the most of your code diary, follow these tips:1. Make it a habit: Set aside a few minutes each day towrite in your diary. This can be at the beginning or end of your workday, or during a break.2. Be consistent: Use the same format and language for each entry. This will make it easier to review and compare your entries over time.3. Review regularly: Set aside time each week or month to review your diary. Look for patterns in your work, identify areas for improvement, and celebrate your achievements.4. Share with others: Consider sharing your diary witha mentor, colleague, or friend. This can help you get feedback, learn from others, and stay accountable.5. Use it as a reference: When you encounter a similar challenge or task in the future, refer to your diary for solutions and ideas.Conclusion。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

教朋友们用代码做一幅漂亮的日志,作品出处,转自网络:
一、HRML在线编辑器地址:/editor.asp
打开编辑器,点上面最下一排第9个符号插入表格,如下设置:
最上面四组就按图片上设置,单元间距和单元边框是这张图片显示多宽,可以随你的想法输入,一般线条的宽输入1PX到10PX就可以了,在“背景图片”那儿插入你想放上去
的图片地址。

点确定后,桌面上出现编辑的状态,然后在图片上插入光标,如果不能插上光标,就在左下角点一下源码在点回编辑,就可以了,插上光标后跟做第一层一样的,可以根据自己的喜欢放第二层,第三层等很多层的图片,宽度也自己掌握。

做好边框如下:
然后把上面边框宽的部份删一些跟左右一样,下面不用管,鼠标插在图片的中间,向下击回车键,就能看出边框的效果了,或者点下面的预览也行。

效果如下:
然后点击下面的源代码(在编辑器的左下方),复制全部代码,到你空间的写日志地方,点开高级,打开HTML编辑,把代码粘贴上去。

在粘贴前要把里面的符号全部删掉,那样
才会显示正确。

然后在右上角有一个返回,点击返回,就可以看到效果,然后在边框中间写日志和加上你喜欢的图片就行了。

朋友们喜欢日志做多长,就敲击回车键。

边框会自然往下延伸的。

二、下面的代码都是在HTML的编辑状态下使用的
1、字在图片上流动的代码 <DIV> <TABLE style="WIDTH: 380px; HEIGHT: 256px" width=380 border=0> <TBODY> <TR> <TD background=图片地址 height=250> <P>
<MARQUEE style="WIDTH: 365px; HEIGHT: 238px" scrollAmount=1 scrollDelay=50 direction=up width=365 height=238>图片上的文字
</MARQUEE></P></TD></TR></TBODY>
背景音乐代码
2、免费播放器的加法:
</textarea><embed src=http://你的背景音乐地址 width=0 height=0 loop=
true> (此代码不显播放器)
</textarea><embed src=http://你的背景音乐地址 width=2 height=2 loop=
true> (此代码显播放器)
3、图片羽化代码:
圆形渐变透明<center><img src="图片地址"
style="filter=alpha(opacity=100,style=2,finishopacity=0)"></center>
X形渐变透明<center><img src="图片地址"
style="filter=alpha(opacity=100,style=3,finishopacity=0)"></center> 字体滚动代码 <MARQUEE behavior=alternate>输入的内容</MARQUEE>
图片动的羽化代码 <marquee behavior=alternate><BR>
<img src="这里放图的地址" style="FILTER:
alpha(opacity=100,style=2)"width=300><BR>
</marquee></p>
方形<CENTER><img src="这里放图地址" style="FILTER:
alpha(opacity=100,style=2)"width=300>
</CENTER>
多张图片滚动代码:
<TABLE cellSpacing=0 cellPadding=0 width="70%" align=center border=0> <TBODY>
<TR>
<TD align=middle>
<MARQUEE>
<P align=center><IMG src="图地址"></P></MARQUEE></TD>
<TD align=middle>
<MARQUEE>
<P align=center><IMG src="图地址"></P></MARQUEE></TD>
<TD align=middle>
<MARQUEE>
<P align=center><IMG src="图地址"></P></MARQUEE></TD>
<TD align=middle>
<MARQUEE>
<P align=center><IMG src="图地址
"></P></MARQUEE></TD></TR></TBODY></TABLE></P>
三、在边框中加上现成的图片和FLASH图片、以及写文章就跟你平时做日志是一样的。

能够很熟练的用好上面的代码,你就可以做好一幅漂亮完整的音画了,同时也是按你的想法做出来的,很能表达你自己的意思,祝朋友们早日学会,还有不明白处,可以问我,
祝友友们玩得开心!
如果我找到好的代码我会继续加在这篇日志上。

相关文档
最新文档