★ doc flabby Posted January 22, 2008 Report Posted January 22, 2008 (edited) As alot of people find it hard to find to the time to contribute, or would like a nice open and shut task.I'm introducing the weekly coding challenge! You can collaborate or work on your own! Week 1 is nice and easy Week 1--------- Background-------------TCP Needs a way to log stuff. To files and to the console. The current way is to use Console.WriteLine. This is not very good, and provides no way to filter messages. Also its not possible to write to a log file and to screen. A new way of logging events is needed. Whats needed----------------- A way to record different levels of logging (eg. Error, Warning, Info, Debug)Support most types of data (including byte arrays) in human readable form) I suggest making use of String formatting {0}http://blog.stevex.net/index.php/string-fo...ting-in-csharp/ A Logging Interface (which all Logging classes implement)A Class that logs to screen.A Class that logs to a file. A good way to start would be to start with the attached sample code.You can change anything you want. Names and functions are just suggestions. Submission Requirements------------------------------ Zipped and attached to a post to this thread.Must be Licenced GPL2 or compatible OS licence. eg BSD.Must be in C#Do!@#$%^&*ent where you think is necessery (ie clever stuff that isnt obvious)Week1.zip Edited January 22, 2008 by doc flabby Rediscover online gaming. Get Subspace.Owner of the PlaySubSpace Network (level 0 BanG) and PSSF server
★ CypherJF Posted January 22, 2008 Report Posted January 22, 2008 Why reinvent the wheel other then forcing someone to release it under GPL? Use Apache Logging <http://logging.apache.org/>; licensed under the Apache Commons License <http://logging.apache.org/log4net/license.html>. Owner/Operator of Omega Fire
🜲 Samapico Posted January 23, 2008 Report Posted January 23, 2008 heh... good idea. Though I don't think I'll do much this week... I'm trying to get some stuff finished on DCME so I can finally release all those fixed bugs. DCME is currently in a not-compilable state . And I also need to code something for 17th... http://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Half-Life_Black_Mesa_logo.svg/120px-Half-Life_Black_Mesa_logo.svg.pngDCME co-developerSSCU 17th Parallel sysop
★ doc flabby Posted January 23, 2008 Author Report Posted January 23, 2008 (edited) Why reinvent the wheel other then forcing someone to release it under GPL? Use Apache Logging <http://logging.apache.org/>; licensed under the Apache Commons License <http://logging.apache.org/log4net/license.html>.Must be Licenced GPL2 or compatible OS licence. eg BSD. Apache Commons License is compatable with GPL. http://www.fsf.org/licensing/licenses/ I never said you had to use all your own code either. Just comply with the entry requirements. Intergrating 3rd Party Tools into a project is a task in itself. Its rarely just a case of plug it in and it works. I'm more than happy if someone takes log4net, makes the necessey changes and submits that. Edited January 23, 2008 by doc flabby Rediscover online gaming. Get Subspace.Owner of the PlaySubSpace Network (level 0 BanG) and PSSF server
★ D1st0rt Posted January 23, 2008 Report Posted January 23, 2008 Here's the logger I wrote for ChatBot that you can use (released here under MIT X11). The architecture is a little different than what you asked for, but it achieves the same functionality aside from array formatting (which could be added quite easily). logger.zip _UU___UU__SSSSS____AAA____UU___UU__SSSSS____AAA____UU___UU_SS_______AAAAA___UU___UU_SS_______AAAAA___UU___UU__SSSSS__AA___AA__UU___UU__SSSSS__AA___AA__UU___UU______SS_AAAAAAA__UU___UU______SS_AAAAAAA___UUUUU___SSSSS_AA____AA___UUUUU___SSSSS_AA____AAJ.C. Dento> prime example of why america will never be a world super power.Moscato> d1 is mad he will never have a job outside subspaceI can't see this because I turned signatures off. ps VT
★ CypherJF Posted January 24, 2008 Report Posted January 24, 2008 log4j was pretty easy to use... include the JAR file in the classpath and add the following to your class file private static final Logger logger = Logger.getLogger(ClassName.class); bam, done. Looks from the FAQ all you need is: Here is the suggested usage template: public class Foo { private static readonly ILog log = LogManager.GetLogger(typeof(Foo)); ... other code } An equivalent and more portable solution, though slightly longer, is to use the declaring type of the static constructor. public class Foo { private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); ... other code } Note: the .NET Compact Framework 1.0 does not support System.Reflection.MethodBase.GetCurrentMethod(). Owner/Operator of Omega Fire
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now