{"id":21627107,"url":"https://github.com/improveTheWorld/SmartLog","last_synced_at":"2025-07-17T11:31:41.257Z","repository":{"id":221413753,"uuid":"693775500","full_name":"improveTheWorld/SmartLog","owner":"improveTheWorld","description":"iLogger is a highly efficient and easy-to-use logging library for .NET applications. Its intuitive API allows for quick integration with minimal code. Features include metadata inclusion, variable tracking, and namespace-focused logging. Customize your logging criteria for granular control with minimal performance overhead.","archived":false,"fork":false,"pushed_at":"2024-12-04T12:15:45.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T07:47:01.217Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/improveTheWorld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-19T17:29:52.000Z","updated_at":"2024-12-04T12:15:48.000Z","dependencies_parsed_at":"2024-12-04T13:34:49.108Z","dependency_job_id":null,"html_url":"https://github.com/improveTheWorld/SmartLog","commit_stats":null,"previous_names":["improvetheworld/ilogger","improvetheworld/smartlog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/improveTheWorld/SmartLog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/improveTheWorld%2FSmartLog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/improveTheWorld%2FSmartLog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/improveTheWorld%2FSmartLog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/improveTheWorld%2FSmartLog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/improveTheWorld","download_url":"https://codeload.github.com/improveTheWorld/SmartLog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/improveTheWorld%2FSmartLog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265600590,"owners_count":23795721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T01:15:34.819Z","updated_at":"2025-07-17T11:31:41.251Z","avatar_url":"https://github.com/improveTheWorld.png","language":"C#","funding_links":["https://www.paypal.com/donate/?hosted_button_id=SJTG7U2E6PC4W"],"categories":[],"sub_categories":[],"readme":"\n🎉 Intelligent Logging with SmartLog\n===================================\n\nWhether you're monitoring a specific class instance or tracking a variable change, SmartLog doesn't just observe—it actively assists you in maintaining complete transparency in your application's runtime environment.\n\nThis high-performance logging library is built to accommodate various logging scenarios. It's versatile, catering to different needs and customizable, allowing you to focus on specific variables or contexts. This ensures that you can trace your data modifications in real-time, gaining profound insights into your application's flow.\n\nAt the heart of SmartLog's functionality lies its ability to offer different granularities of log targeting, its flagship feature. You can activate logging exclusively for specific instances, contexts, or namespaces. Furthermore, the logger allows customizing powerful validation functions that direct the logging process, determining what gets logged at runtime.\n\nWith SmartLog, the tasks of debugging and monitoring your application become streamlined and precise, granting you full authority over what, when, and where to log.\n\nEmbark on a journey of intelligent, context-aware logging with SmartLog. Join the evolution in debugging and monitoring now!\n\nTo help keep this project vibrant, active, and free, **💌 [Donate Here](https://www.paypal.com/donate/?hosted_button_id=SJTG7U2E6PC4W) 💌**\n\n💻 Usage\n--------\n\n\n\nIncorporating SmartLog is straightforward. Include it in your class and use the different `Log` levels methods to generate a log entry. Manage contexts and target individual variables with ease. The `Config` object makes adjusting the logger configuration simple.\nThe `SmartLog` library offers a diverse and flexible logging mechanism catering to varied logging needs. This guide showcases some of its prominent features.\n\n### Getting Started\n\nEnsure you have the following namespace imported:\n\n```csharp\nusing iCode.Log;\n\n```\nStart logging:\n```csharp\n iLogger.Info(\"Hello world!!\");\n```\n### Configuration\n\nInitialize and configure the logger:\n\n```csharp\nConfig loggerConfiguration = iLogger.Filters;\nloggerConfiguration.IncludeTimestamp = true;\nloggerConfiguration.IncludeInstanceName = true;\nloggerConfiguration.IncludeTaskId = true;\nloggerConfiguration.IncludeThreadId = true;\n```\n\n\n\n### Instance Targeting\n\nTarget specific instances for logging:\n\n```csharp\nclass MyNumeric\n{\n    public void Update(int newValue)\n    {\n        this.Info($\"New value assigned: {numericValue}\");\n    }\n    ...\n\n}\n```\n\n```csharp\nMyNumeric firstObject = new MyNumeric();\nfirstObject.WatchByLogger(\"FirstObject\");\nfirstObject.Update(5);\n\nMyNumeric secondObject = new MyNumeric();\nsecondObject.UpdateAndLogValue(5);\n```\n\n\nIn this example, only `firstObject` will generate a log when updated, because it's being specifically watched by the logger.\n\n### All Instances Targeting\n\nYou can also activate logging for all objects without the need for prior declaration:\n\n```csharp\nloggerConfiguration.WatchAllObjects();\n```\n\nWith the above configuration, all updates to `LoggableObject` instances will be logged.\n\n### Conditional Logging based on Object Characteristics\n\nImplement custom logic to decide whether an object should generate logs:\n\n```csharp\nloggerConfiguration.RequesterValidation = (x) =\u003e \n{\n    if (x is NumericLoggableObject loggableObject)\n    {\n        return loggableObject.IsOdd();\n    }\n    return true;\n};\n```\n\nHere, logging will only occur if the `numericValue` inside the `LoggableObject` is odd.\n\n### Type-based Logging\n\nLog based on the type of the object:\n\n```csharp\nloggerConfiguration.RequesterValidation = (x) =\u003e x is NumericLoggableObject;\n```\n\nWith this, only instances of `NumericLoggableObject` will generate logs.\n\nWith SmartLog, the possibilities are limitless. Your logs can now be more insightful and versatile, assisting you in your development process.\n\n🎯 Potential Usages\n-------------------\n\nSmartLog can be employed in numerous ways to assist in system development and debugging:\n\n* Customized Debugging\n* Performance Monitoring\n* Security Auditing\n* User Behavior Analysis\n* Fine-grained Error Tracking\n* Educational Purposes\n* Development Teams\n\nEach usage of SmartLog brings you closer to a more streamlined and efficient development and debugging process.\n\n🔍 Description\n--------------\n\n\n**Buffer Enabled Mode**\n\nWhen the BufferEnabled property is set to true, instead of writing log entries immediately to the various logging targets (like console or file), the logger first stores them in a buffer. This buffering process makes use of the Channel class to hold the log entries.\n\n1. Advantages of Buffering:\n\n   Performance Improvement: In some scenarios, writing logs to their destination can be a slow operation, especially when the destination is a remote server or a slow disk. By using a buffer, the application can continue its main operation without waiting for the log writing to complete. The actual writing can then be done in the background.\n\n   Asynchronous Processing: With the buffer in place, logs can be processed asynchronously. This is evident from the use of the Loop method which continuously reads messages from the Buffer and logs them. This way, the main application isn't blocked by the logging process.\n2. Working:\n\n   - When BufferEnabled is set to true, the Buffer is initialized (if it hasn't been already).\n   - Any log entry that needs to be logged is put into the buffer using the PutInQueue method.\n   - The Loop method continuously checks the buffer for new log entries. When it finds a log entry, it sends the log message to all the logger targets in the loggerTargets list.\n3. When is the Buffer used? The PutInQueue method decides whether to put the log entry into the buffer or to log it immediately. If bufferEnabled is true, the log entry is added to the buffer; otherwise, it's logged immediately.\n4. Things to Note: Debugging: The logger has a DebugLogger flag. When this is set to true, the logger will also print debug trace logs that show the internal working of the logger. This is particularly useful for troubleshooting.\n5. Threading: Given that the logger might be used from multiple threads, locks and channels are used to ensure thread safety.\n\nIn Summary:\nThe BufferEnabled mode in the iLogger class provides a way to buffer log entries for asynchronous processing, potentially improving the performance of the application by decoupling the log-writing process from the main operation of the application.\n\n**Buffer Disabled Mode**\n\nThe use of `BufferEnabled` set to `false`, meaning immediate or synchronous logging, might be preferable in some scenarios:\n\n1. **Critical Systems** : In systems where logs are critically important, such as financial transactions, you'd want to be certain that every transaction is logged immediately. The potential danger of buffering in such a scenario is data loss in case of system failures or crashes before buffered logs have been flushed.\n2. **Debugging during Development** : When developing and debugging, it's often easier to have logs written out immediately to understand the flow of the program in real-time.\n3. **Low Volume Logging** : If your application doesn't generate a large volume of log messages, then the performance benefit of asynchronous logging might be negligible. In such cases, synchronous logging (i.e., `BufferEnabled` set to `false`) simplifies the process.\n4. **Avoiding Memory Overhead** : Buffering logs requires memory. If you're running in a resource-constrained environment, it might be beneficial to log directly rather than buffer.\n5. **Real-time Monitoring** : If you have a monitoring system or a logging tool that's analyzing logs in real-time, then asynchronous logging might introduce unwanted delays.\n6. **Short-lived Processes** : For processes that start up, do their work, and shut down quickly (e.g., certain batch jobs or scripts), buffering might not provide much benefit, and there could be a risk that the buffer doesn't get completely flushed before the process exits.\n7. **Simpler Error Handling** : If there's an issue with writing a log (e.g., a disk is full), you might want to know immediately, so you can handle the error right where it happens. With buffering, the error might occur asynchronously, making it a bit trickier to handle.\n8. **Ensuring Sequential Order** : In heavily multi-threaded environments, buffering might introduce a scenario where logs from different threads get mixed in a non-sequential manner. Direct logging ensures that logs are written in the exact sequence they occur.\n\nWhile there are benefits to synchronous logging, remember that it does come at the potential cost of performance. In scenarios where performance is a critical concern, and the volume of logs is high, asynchronous logging (i.e., `BufferEnabled` set to `true`) would likely be the better choice. But, as with many things in software design, it's all about evaluating and balancing trade-offs based on the specific needs of your application.\n\n🔐 License\n----------\n\n* For free software use, this project is licensed under the Apache V2.0  - see the [LICENSE](./LICENSE-APACHE.txt) file for details. \n* For commercial software use, see the [LICENSE\\_NOTICE](./LICENSE_NOTICE.md) license file.\n\n📬 Contact\n----------\n\nHere’s the corrected version of your sentence:\n\nIf you have any questions, suggestions, or would like to purchase SmartLog for commercial software use, please feel free to reach out to us.:\n\n* [Tec-Net](mailto:tecnet.paris@gmail.com)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FimproveTheWorld%2FSmartLog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FimproveTheWorld%2FSmartLog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FimproveTheWorld%2FSmartLog/lists"}