Merge branch 'feature/asp_anime' into 'develop'
开发者工具 See merge request aibis-dream/aibis-dream!293
This commit is contained in:
@@ -94,7 +94,7 @@ MonoBehaviour:
|
||||
m_Padding:
|
||||
m_Left: 30
|
||||
m_Right: 45
|
||||
m_Top: 50
|
||||
m_Top: 55
|
||||
m_Bottom: 30
|
||||
m_ChildAlignment: 4
|
||||
m_Spacing: 0
|
||||
|
||||
@@ -12469,6 +12469,7 @@ Transform:
|
||||
- {fileID: 1317294298}
|
||||
- {fileID: 1620453322}
|
||||
- {fileID: 369430730}
|
||||
- {fileID: 1068968715}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1015707783
|
||||
@@ -12564,6 +12565,50 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1068968714
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1068968715}
|
||||
- component: {fileID: 1068968716}
|
||||
m_Layer: 0
|
||||
m_Name: Log Kit
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1068968715
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1068968714}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1009826577}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1068968716
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1068968714}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 647335bd723dab94ea97b993d03af61e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1076102355
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfe8aa3a0b2c8c144af979bb5714ae85
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AibisDream.Kit
|
||||
{
|
||||
internal class FileLogger
|
||||
{
|
||||
private StreamWriter _fileWriter;
|
||||
|
||||
private readonly string _filename;
|
||||
private readonly string _filePath;
|
||||
private readonly int _saveDays;
|
||||
|
||||
private static string CurrentDay => DateTime.Now.ToString("yyyyMMdd");
|
||||
private string _currentLogDay;
|
||||
private string _preSavePath;
|
||||
|
||||
/// <summary>
|
||||
/// 开始打印
|
||||
/// </summary>
|
||||
public FileLogger(string filename, string filePath, int saveDays)
|
||||
{
|
||||
_filename = filename;
|
||||
_filePath = filePath.TrimEnd('/') + "/";
|
||||
_saveDays = saveDays;
|
||||
StartNewFile();
|
||||
DeleteOldFile();
|
||||
_currentLogDay = CurrentDay;
|
||||
Write("*********************************************************\nSystem Start at " +
|
||||
DateTime.Now.ToString("HH:mm:ss") +
|
||||
"\n*********************************************************\n");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新建文件
|
||||
/// </summary>
|
||||
private void StartNewFile()
|
||||
{
|
||||
if (_fileWriter != null)
|
||||
{
|
||||
_fileWriter.Close();
|
||||
_fileWriter.Dispose();
|
||||
}
|
||||
|
||||
_fileWriter = null;
|
||||
|
||||
if (!Directory.Exists(_filePath))
|
||||
{
|
||||
Directory.CreateDirectory(_filePath);
|
||||
}
|
||||
|
||||
_fileWriter = File.AppendText(_filePath + string.Format(_filename, DateTime.Now));
|
||||
}
|
||||
|
||||
public void Write(string content)
|
||||
{
|
||||
System.Globalization.CultureInfo.CurrentCulture.ClearCachedData();
|
||||
if (_currentLogDay != CurrentDay)
|
||||
{
|
||||
StartNewFile();
|
||||
DeleteOldFile();
|
||||
_currentLogDay = CurrentDay;
|
||||
}
|
||||
|
||||
if (_fileWriter is { BaseStream: { CanWrite: true } })
|
||||
_fileWriter.WriteLine(content);
|
||||
}
|
||||
|
||||
void DeleteOldFile()
|
||||
{
|
||||
var fileList = Directory.GetFiles(_filePath);
|
||||
if (fileList.Length > _saveDays)
|
||||
{
|
||||
_preSavePath = _filePath + string.Format(this._filename, DateTime.Now.AddDays(-_saveDays + 1));
|
||||
foreach (var t in fileList)
|
||||
{
|
||||
if (string.CompareOrdinal(_preSavePath, t) == 1)
|
||||
{
|
||||
File.Delete(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (_fileWriter == null)
|
||||
return;
|
||||
|
||||
Write("*********************************************************\nSystem Shutdown at " +
|
||||
DateTime.Now.ToString("HH:mm:ss") +
|
||||
"\n*********************************************************\n");
|
||||
|
||||
_fileWriter.Flush();
|
||||
_fileWriter.Close();
|
||||
_fileWriter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2dc29290b545c1974b6473534df853
|
||||
timeCreated: 1741445068
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.Kit
|
||||
{
|
||||
internal class LogKit : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件名称格式
|
||||
/// 请注意,不要删除时间格式,否则会造成保存不成功
|
||||
/// </summary>
|
||||
public static string LogFileName => "Log{0:_yyyy_MM_dd}.txt";
|
||||
|
||||
/// <summary>
|
||||
/// 日志文件路径
|
||||
/// </summary>
|
||||
public static string LogPath => Application.streamingAssetsPath + "/LogFile";
|
||||
|
||||
/// <summary>
|
||||
/// 日志保存最近几天的内容
|
||||
/// </summary>
|
||||
public const int SaveDays = 30;
|
||||
|
||||
/// <summary>
|
||||
/// 每一行的打印内容
|
||||
/// </summary>
|
||||
private static string LogContent => "--------------------------" + Time + "--------------------------\n{0}\n{1}";
|
||||
|
||||
private FileLogger _fileLogger;
|
||||
|
||||
private static string Time => DateTime.Now.ToString("[HH:mm:ss.fffd]");
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
DontDestroyOnLoad(gameObject);
|
||||
_fileLogger = new FileLogger(LogFileName, LogPath, SaveDays);
|
||||
Application.logMessageReceivedThreaded += LogMessage;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void LogMessage(string condition, string stackTrace, LogType type)
|
||||
{
|
||||
if (!type.Equals(LogType.Warning))
|
||||
{
|
||||
_fileLogger?.Write(string.Format(LogContent, condition, stackTrace));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_fileLogger?.OnDestroy();
|
||||
_fileLogger = null;
|
||||
Application.logMessageReceivedThreaded -= LogMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 647335bd723dab94ea97b993d03af61e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user