/// <summary> /// Log a message. /// </summary> /// <param name="message">Message to log. </param> /// <param name="level">Error severity level. </param> public void Log(Log.Level level, string message) { FileStream fileStream = null; StreamWriter writer = null; StringBuilder messageBuilder = new StringBuilder(); try { fileStream = _logFile.Open(FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read); writer = new StreamWriter(fileStream); // Set the file pointer to the end of the file writer.BaseStream.Seek(0, SeekOrigin.End); // Create the message messageBuilder.Append(System.DateTime.Now.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss")) .Append(" | ").Append(level.ToString()).Append(" | ").Append(message); // Force the write to the underlying file writer.WriteLine(messageBuilder.ToString()); writer.Flush(); } finally { if (writer != null) { writer.Close(); } } }
public void Save() { PlayerPrefs.SetString(NexusKindTag, nexusKind.ToString()); //PlayerPrefs.SetString(PhantasmaRPCTag, this.phantasmaRPCURL); PlayerPrefs.SetString(PhantasmaBPTag, this.phantasmaBPURL); PlayerPrefs.SetString(NeoRPCTag, this.neoRPCURL); PlayerPrefs.SetString(NeoscanAPITag, this.neoscanURL); PlayerPrefs.SetString(NexusNameTag, this.nexusName); PlayerPrefs.SetString(CurrencyTag, this.currency); PlayerPrefs.SetString(GasPriceTag, this.feePrice.ToString()); PlayerPrefs.SetInt(SFXTag, this.sfx ?1:0); PlayerPrefs.SetString(LogLevelTag, this.logLevel.ToString()); PlayerPrefs.SetInt(LogOverwriteModeTag, this.logOverwriteMode ? 1 : 0); PlayerPrefs.Save(); Log.Write("Settings: Save: Nexus kind: " + nexusKind.ToString() + "\n" + " Phantasma BP: " + phantasmaBPURL + "\n" + " Neo RPC: " + neoRPCURL + "\n" + " Neoscan: " + neoscanURL + "\n" + " Nexus name: " + nexusName + "\n" + " Currency: " + currency + "\n" + " Sfx: " + sfx + "\n" + " Fee price: " + feePrice + "\n" + " Log level: " + logLevel.ToString() + "\n" + " Log overwrite: " + logOverwriteMode ); }
private void RenderHeader( ) { // build the title bar with all filtering options GUILayout.BeginHorizontal(titleBarStyle, GUILayout.Height(32f)); // render out the available category buttons and prefix with all/none GUILayout.Label("Category:", GUILayout.Width(68f)); category = (Log.Category)EditorGUILayout.EnumMaskField(category); GUILayout.Space(8f); // display a level slider we can adjust the log level with GUILayout.Label("Log Level:", GUILayout.Width(68f)); logLevel = GUILayout.HorizontalSlider(logLevel, 0f, 4f, GUILayout.Width(128f)); logLevel = Mathf.Clamp(Mathf.RoundToInt(logLevel), 0, 4); level = (Log.Level)Mathf.RoundToInt(logLevel); string label = level.ToString( ); GUILayout.Label("(" + label + ")"); GUILayout.FlexibleSpace( ); // render out the text search filter area GUILayout.Label("Keyword:"); keyword = GUILayout.TextField(keyword == null ? "" : keyword, GUILayout.Width(128f)); GUILayout.Space(4f); if (GUILayout.Button("Actions", EditorStyles.toolbarDropDown)) { GenericMenu toolsMenu = new GenericMenu( ); toolsMenu.AddItem(new GUIContent("Copy Active Log"), false, CopyActiveLog); string pauseMenuText = pauseFrame == null ? "Pause Log Viewer" : "Resume Log Viewer"; toolsMenu.AddItem(new GUIContent(pauseMenuText), false, PauseLog); toolsMenu.AddSeparator(""); toolsMenu.AddItem(new GUIContent("Redirect To Console"), Log.Instance.IsConsoleOn( ), RedirectToConsole); toolsMenu.AddItem(new GUIContent("Intercept Console"), Log.Instance.IsInterceptOn( ), InterceptConsole); toolsMenu.AddSeparator(""); string toggleWatches = (logWatch == null) ? "Show Watches" : "Hide Watches"; toolsMenu.AddItem(new GUIContent(toggleWatches), false, ToggleWatchWindow); toolsMenu.AddItem(new GUIContent("Export to 'log.csv'"), false, ExportToCSV); toolsMenu.AddSeparator(""); toolsMenu.AddItem(new GUIContent("Clear Log"), false, ClearLog); toolsMenu.DropDown(new Rect(position.width - 200f, 16f, 0, 16)); } GUILayout.Space(2f); GUILayout.EndHorizontal( ); }
public void LogMsg(string logMessage, Log.Level level) { try { // log string to text file _logFile.WriteLine(level.ToString() + " " + logMessage); _logFile.Flush(); } catch (IOException ioExp) { Log.Instance.UnregisterObserver(this); Log.Instance.LogMsg(String.Format("Unregistered observer {0}: exception {1}", this.ToString(), ioExp.Message), Log.Level.Error); } }
/// <summary> /// Log message. /// </summary> public void Write(Log.Level level, string format, params object[] args) { string dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string message; if (args.Length > 0) { message = string.Format(format, args); } else { message = format; } Write(dt + ' ' + level.ToString() + ' ' + message); }
public void Save() { PlayerPrefs.SetString(NexusKindTag, nexusKind.ToString()); //PlayerPrefs.SetString(PhantasmaRPCTag, this.phantasmaRPCURL); PlayerPrefs.SetString(PhantasmaBPTag, this.phantasmaBPURL); PlayerPrefs.SetString(GasPriceTag, this.feePrice.ToString()); PlayerPrefs.SetString(NeoGasFeeTag, this.neoGasFee.ToString()); PlayerPrefs.SetString(NeoRPCTag, this.neoRPCURL); PlayerPrefs.SetString(NeoscanAPITag, this.neoscanURL); PlayerPrefs.SetString(EthereumNetworkTag, this.ethereumNetwork.ToString()); PlayerPrefs.SetString(EthereumLocalnetSoulContractTag, this.ethereumLocalnetSoulContract.ToString()); PlayerPrefs.SetString(EthereumLocalnetKcalContractTag, this.ethereumLocalnetKcalContract.ToString()); PlayerPrefs.SetString(EthereumRPCTag, this.ethereumRPCURL); PlayerPrefs.SetString(EthereumGasPriceGweiTag, this.ethereumGasPriceGwei.ToString()); PlayerPrefs.SetString(EthereumTransferGasLimitTag, this.ethereumTransferGasLimit.ToString()); PlayerPrefs.SetString(EthereumTokenTransferGasLimitTag, this.ethereumTokenTransferGasLimit.ToString()); PlayerPrefs.SetString(NexusNameTag, this.nexusName); PlayerPrefs.SetString(CurrencyTag, this.currency); PlayerPrefs.SetInt(SFXTag, this.sfx ?1:0); PlayerPrefs.SetString(UiThemeNameTag, this.uiThemeName); PlayerPrefs.SetString(LogLevelTag, this.logLevel.ToString()); PlayerPrefs.SetInt(LogOverwriteModeTag, this.logOverwriteMode ? 1 : 0); PlayerPrefs.Save(); Log.Write("Settings: Save: Nexus kind: " + nexusKind.ToString() + "\n" + " Phantasma BP: " + phantasmaBPURL + "\n" + " Fee price: " + feePrice + "\n" + " Neo RPC: " + neoRPCURL + "\n" + " Neoscan: " + neoscanURL + "\n" + " Neo GAS fee: " + neoGasFee + "\n" + " Ethereum network: " + ethereumNetwork + "\n" + " Ethereum localnet SOUL contract: " + ethereumLocalnetSoulContract + "\n" + " Ethereum localnet KCAL contract: " + ethereumLocalnetKcalContract + "\n" + " Ethereum RPC: " + ethereumRPCURL + "\n" + " Ethereum gas price (Gwei): " + ethereumGasPriceGwei + "\n" + " Ethereum transfer gas limit: " + this.ethereumTransferGasLimit + "\n" + " Ethereum token transfer gas limit: " + this.ethereumTokenTransferGasLimit + "\n" + " Nexus name: " + nexusName + "\n" + " Currency: " + currency + "\n" + " Sfx: " + sfx + "\n" + " UI Theme: " + uiThemeName + "\n" + " Log level: " + logLevel.ToString() + "\n" + " Log overwrite: " + logOverwriteMode ); }
public string ToCSV() { return(string.Format("{0:F2},{1:F0},{2},{3},\"{4}\",\"{5}\"", time, frame, category.ToString(), level.ToString(), SanitizeString(message), SanitizeString(stack))); }
public void LogCallback(Log.Level level, String message) { string dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Console.WriteLine(dt + ' ' + level.ToString() + ' ' + message); }
public void log(Log.Level l, object o) => logInner(l, line(l.ToString(), o));
public void log(Log.Level l, object o, Object context = null) => logInner(l, line(l.ToString(), o), context.opt());
public void log(Log.Level l, LogEntry entry) { logInner(l, entry.withMessage(line(l.ToString(), entry.message))); _messageLogged.push(new LogEvent(l, entry)); }