📄 filelog.java
字号:
import java.util.*;
import java.io.*;
import LogRequest;
public class FileLog
{
static FileLog m_filelog = null;
FileOutputStream m_fos = null;
PrintStream m_ps = null;
private FileLog(String strFileName)
throws IOException
{
m_fos = new FileOutputStream(strFileName);
m_ps = new PrintStream(m_fos);
}
private void log(LogRequest lr,String strLine)
{
if(strLine != null && strLine.length() > 0)
{
m_ps.println(strLine);
}
}
private void close()
{
if(m_ps != null)
{
m_ps.close();
}
}
public static boolean openLog(String strFileName)
{
try
{
m_filelog = new FileLog(strFileName);
}
catch(Exception e)
{
System.out.println(e);
System.out.println("FileLog.openLog : unexpected exit !");
m_filelog = null;
return false;
}
return true;
}
public static synchronized void log(LogRequest lr,String strLine,long lLogRequests)
{
if(m_filelog != null && lr.isRequested(lLogRequests))
{
if(lr.isRequested(LogRequest.LOG_TIME))
{
long lCurrTime = System.currentTimeMillis();
Date date = new Date(lCurrTime);
m_filelog.log(lr,date.toLocaleString() + ">" + strLine);
}
else
{
m_filelog.log(lr,strLine);
}
}
}
public static void closeLog()
{
if(m_filelog != null)
{
m_filelog.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -