本文整理汇总了C#中Log类的典型用法代码示例。如果您正苦于以下问题:C# Log类的具体用法?C# Log怎么用?C# Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Log类属于命名空间,在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public static bool Execute(ProjectProperties properties, Log log)
{
Console.WriteLine("compiling");
var processSettings = new ProcessStartInfo();
processSettings.FileName = properties.CscPath;
processSettings.Arguments = properties.FormatCscArguments();
log.WriteLine("Executing {0}", processSettings.FileName);
log.WriteLine("Csc Arguments: {0}", processSettings.Arguments);
processSettings.CreateNoWindow = true;
processSettings.RedirectStandardOutput = true;
processSettings.UseShellExecute = false;
Process cscProcess = null;
try
{
cscProcess = Process.Start(processSettings);
}
catch (Win32Exception)
{
Console.WriteLine("ERROR: csc.exe needs to be on the path.");
return false;
}
var output = cscProcess.StandardOutput.ReadToEnd();
log.WriteLine(output);
cscProcess.WaitForExit();
if (output.Contains("error CS")) return false;
return true;
}
示例2: Start
public void Start()
{
if (_running)
throw new InvalidOperationException("Process is already running");
if (!string.IsNullOrEmpty(LogFile))
{
_log = new Log(LogFile, BufferSize, ReliableLogging);
_log.MaxNumberBackups = MaxNumberOfLogBackups;
_log.MaxSize = MaxLogSize;
}
_process = new Process();
_process.StartInfo.CreateNoWindow = true;
_process.StartInfo.RedirectStandardError = true;
_process.StartInfo.RedirectStandardInput = true;
_process.StartInfo.RedirectStandardOutput = true;
_process.StartInfo.UseShellExecute = false;
_process.StartInfo.FileName = ImagePath;
_process.StartInfo.Arguments = Arguments
.Select(a => a.Replace("\"", "\\\""))
.Select(a => a.Contains(" ") ? "\"" + a + "\"" : a)
.Aggregate(new StringBuilder(), (sb, a) => sb.Append(a).Append(' '))
.ToString()
.Trim();
_process.StartInfo.WorkingDirectory = WorkingDirectory;
_process.ErrorDataReceived += new DataReceivedEventHandler(_process_OutputDataReceived);
_process.OutputDataReceived += new DataReceivedEventHandler(_process_OutputDataReceived);
_process.Exited += new EventHandler(_process_Exited);
_process.Start();
_process.BeginErrorReadLine();
_process.BeginOutputReadLine();
_running = true;
}
示例3: FrmBaseTableView
private DataTable dataTable; // загруженная таблица
/// <summary>
/// Конструктор
/// </summary>
private FrmBaseTableView()
{
InitializeComponent();
errLog = null;
baseAdapter = null;
dataTable = null;
}
示例4: InsertInto
/// <summary>
/// Insert data into table
/// e.g. DDL.InsertInto("Sample", "col1,col2", "10,20");
/// </summary>
/// <param name="sTableName"></param>
/// <param name="sColumns_i"></param>
/// <param name="sValues_i"></param>
public static void InsertInto(string sTableName, string sColumns_i, string sValues_i )
{
using( Log log = new Log( "Glx.DB.DDL.InsertInto()" ) )
{
try
{
string sQuerry = "INSERT INTO " + sTableName + "(";
string[] sColums = Strings.Split(sColumns_i, ",", -1, CompareMethod.Text);
sQuerry = sQuerry + sColums[0];
for (int nIndex = 1; nIndex < sColums.Length; nIndex++)
sQuerry = sQuerry + "," + sColums[nIndex];
sQuerry += ") VALUES(";
string[] sValues = Strings.Split(sValues_i, ",", -1, CompareMethod.Text);
sQuerry = sQuerry + sValues[0];
for (int nIndex = 1; nIndex < sValues.Length; nIndex++)
sQuerry = sQuerry + "," + sValues[nIndex];
sQuerry += ")";
log.PutQuerry( sQuerry);
DBWrapper.ExecuteNonQueryEx(sQuerry);
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
示例5: Write
/// <summary>
/// Writes a single message to the output.
/// </summary>
/// <param name="source">The <see cref="Log"/> from which the message originates.</param>
/// <param name="type">The type of the log message.</param>
/// <param name="msg">The message to write.</param>
/// <param name="context">The context in which this log was written. Usually the primary object the log entry is associated with.</param>
public virtual void Write(Log source, LogMessageType type, string msg, object context)
{
int indent = source.Indent;
string prefix = source.Prefix ?? "";
string[] lines = msg.Split(new[] { '\n', '\r', '\0' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lines.Length; i++)
{
if (i == 0)
{
switch (type)
{
case LogMessageType.Message:
lines[i] = prefix + "Msg: " + new string(' ', indent * 2) + lines[i];
break;
case LogMessageType.Warning:
lines[i] = prefix + "Wrn: " + new string(' ', indent * 2) + lines[i];
break;
case LogMessageType.Error:
lines[i] = prefix + "ERR: " + new string(' ', indent * 2) + lines[i];
break;
}
}
else
{
lines[i] = new string(' ', prefix.Length + 5 + indent * 2) + lines[i];
}
this.WriteLine(source, type, lines[i], context);
}
}
示例6: PostScheduleMessage
public override void PostScheduleMessage(dynamic data)
{
try
{
oAuthTwitter OAuthTwt = new oAuthTwitter();
TwitterAccountRepository fbaccrepo = new TwitterAccountRepository();
TwitterAccount twtaccount = fbaccrepo.getUserInformation(data.UserId, data.ProfileId);
OAuthTwt.CallBackUrl = System.Configuration.ConfigurationSettings.AppSettings["callbackurl"];
OAuthTwt.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["consumerKey"];
OAuthTwt.ConsumerKeySecret = System.Configuration.ConfigurationSettings.AppSettings["consumerSecret"];
OAuthTwt.AccessToken = twtaccount.OAuthToken;
OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret;
OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName;
OAuthTwt.TwitterUserId = twtaccount.TwitterUserId;
#region For Testing
// For Testing
//OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w";
//OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI";
//OAuthTwt.AccessToken = "1904022338-Ao9chvPouIU8ejE1HMG4yJsP3hOgEoXJoNRYUF7";
//OAuthTwt.AccessTokenSecret = "Wj93a8csVFfaFS1MnHjbmbPD3V6DJbhEIf4lgSAefORZ5";
//OAuthTwt.TwitterScreenName = "";
//OAuthTwt.TwitterUserId = "";
#endregion
TwitterUser twtuser = new TwitterUser();
if (string.IsNullOrEmpty(data.ShareMessage))
{
data.ShareMessage = "There is no data in Share Message !";
}
JArray post = twtuser.Post_Status_Update(OAuthTwt, data.ShareMessage);
Console.WriteLine("Message post on twitter for Id :" + twtaccount.TwitterUserId + " and Message: " + data.ShareMessage);
ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
schrepo.updateMessage(data.Id);
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
Log log = new Log();
log.CreatedDate = DateTime.Now;
log.Exception = ex.Message;
log.Id = Guid.NewGuid();
log.ModuleName = "TwitterScheduler";
log.ProfileId = data.ProfileId;
log.Status = false;
LogRepository logRepo = new LogRepository();
logRepo.AddLog(log);
}
}
示例7: getInstance
public static Log getInstance() {
if (Log.s_instance == null) {
Log.s_instance = new Log();
Log.s_instance.Initialize();
}
return Log.s_instance;
}
示例8: fmMain_Load
private void fmMain_Load(object sender, EventArgs e)
{
bool r;
AppMutex = new Mutex(true, "AndonSys.AppHelper", out r);
if (!r)
{
MessageBox.Show("系统已运行!",this.Text);
Close();
return;
}
CONFIG.Load();
log = new Log(Application.StartupPath, "AppHelper", Log.DEBUG_LEVEL);
log.Debug("系统运行");
gdApp.AutoGenerateColumns = false;
LoadApp();
tbApp.Show();
timer.Enabled = true;
}
示例9: VariantValidate
/// <summary>
/// Validates a variant string, returns true if variant string is a correct HVGS nomnclature
/// </summary>
/// <param name="variant"></param>
/// <returns></returns>
public bool VariantValidate(string variant)
{
try
{
Process process = new Process();
if (ApplicationDeployment.IsNetworkDeployed)
process.StartInfo.FileName = ApplicationDeployment.CurrentDeployment.DataDirectory + "\\Executables\\Validator.exe";
else
process.StartInfo.FileName = Application.StartupPath + "\\Executables\\Validator.exe";
process.StartInfo.Arguments = "-v " + "\"" + variant + "\"";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
return bool.Parse(output);
}
catch (Exception ex)
{
// something went wrong, we log it
Log log = new Log(true);
log.write("Error parsing variant: " + variant);
log.write(ex.ToString());
return false;
}
}
示例10: connect_util
private void connect_util()
{
string user_name, password;
int id_user = 0;
user_name = user_name_txt.Text != "" ? user_name_txt.Text : "";
password = password_txt.Text != "" ? password_txt.Text : "";
id_user = db_util.query_user(user_name, password);
if (id_user != 0)
{
log = new Log(id_user);
log.id_log = db_util.insert_log(log);
MainWindow main_window = new MainWindow();
main_window.log = log;
main_window.db_util = db_util;
main_window.Show();
this.Close();
}
else
{
info_lbl.Content = "Something went wrong!\nTry again";
}
}
示例11: ExecuteAppendLog
public void ExecuteAppendLog(Log log)
{
string path = string.Format("../../{0}", this.LogFile);
try
{
if (!File.Exists(path))
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(path))
{
file.WriteLine(layout.Format(log));
}
}
else if (File.Exists(path))
{
using (TextWriter textWriter = new StreamWriter(path, true))
{
textWriter.WriteLine(layout.Format(log));
textWriter.Close();
}
}
}
catch (IOException ex)
{
Console.WriteLine(ex.Message);
}
}
示例12: CanCreateAlarmTypeAndLog
public void CanCreateAlarmTypeAndLog()
{
IRepository<AlarmType> repoA = new AlarmTypeRepository();
AlarmType alarm = new AlarmType();
alarm.NameAlarmType = "PruebaAlarma";
alarm.Description = "Prueba descriptiva alarma";
repoA.Save(alarm);
IRepository<User> repoB = new UserRepository();
User user = new User();
user = repoB.GetById(1);
IRepository<Event> repoC = new EventRepository();
Event eventt = new Event();
eventt = repoC.GetById(2);
IRepository<Log> repoD = new LogRepository();
Log log = new Log();
log.DateTime = DateTime.Now;
log.Text = "Prueba descriptiva log";
log.Event = eventt;
log.User = user;
repoD.Save(log);
}
示例13: GetSnoPoMo
static public string GetSnoPoMo(SqlConnection connect,
Log log,
string productId)
{
string ret = null;
SqlCommand dbCmd = connect.CreateCommand();
dbCmd.CommandType = CommandType.Text;
dbCmd.CommandText = "select top 1 PO from dbo.SnoDet_PoMo (nolock) where [email protected]";
SQLHelper.createInputSqlParameter(dbCmd, "@SnoId", 10, productId);
log.write(LogType.Info, 0, "SQL", "GetSnoPoMo", dbCmd.CommandText);
log.write(LogType.Info, 0, "SQL", "@SnoId", productId);
SqlDataReader sdr = dbCmd.ExecuteReader();
while (sdr.Read())
{
ret=sdr.GetString(0).Trim();
}
sdr.Close();
return ret;
}
示例14: GetCNRSSNList
static public List<string> GetCNRSSNList(SqlConnection connect,
Log log,
int offsetDay)
{
List<string> SNList = new List<string>();
SqlCommand dbCmd = connect.CreateCommand();
dbCmd.CommandType = CommandType.Text;
dbCmd.CommandText = @"select distinct a.SnoId
from Special_Det a
left join ProductAttr b on (a.SnoId = b.ProductID and b.AttrName='CNRSState')
where a.Tp='CNRS'
and a.Udt>=dateadd(dd,@day,getdate())
and b.AttrValue is null";
SQLHelper.createInputSqlParameter(dbCmd, "@day", offsetDay);
log.write(LogType.Info, 0, "SQL", "GetCNRSSNList", dbCmd.CommandText);
log.write(LogType.Info, 0, "SQL", "@day", offsetDay.ToString());
SqlDataReader sdr = dbCmd.ExecuteReader();
while (sdr.Read())
{
SNList.Add(sdr.GetString(0).Trim());
}
sdr.Close();
return SNList;
}
示例15: GetCDSISNList
static public List<string> GetCDSISNList(SqlConnection connect,
Log log,
string snoId,
string tp)
{
List<string> SNList = new List<string>();
SqlCommand dbCmd = connect.CreateCommand();
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.CommandText = "op_CDSIDataUpdate";
SQLHelper.createInputSqlParameter(dbCmd, "@SnoId", 10, snoId);
SQLHelper.createInputSqlParameter(dbCmd, "@tp", 2, tp);
log.write(LogType.Info, 0, "SQL", "GetDNList", dbCmd.CommandText);
log.write(LogType.Info, 0, "SQL", "@SnoId", snoId);
log.write(LogType.Info, 0, "SQL", "@tp", tp);
SqlDataReader sdr = dbCmd.ExecuteReader();
while (sdr.Read())
{
SNList.Add(sdr.GetString(0).Trim());
}
sdr.Close();
return SNList;
}