Skip to content

Nuroferatu/stf_logger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software Tools Factory - Logger

Simple Logger that looks and feels like cout, supports colors and is simlilar to Android Log :)

Platforms

  • Windows
  • Linux
  • Cygwin

Build and Run

Windows

*.sln file + .vcxproj have everything that is needed to run/debug library

Linux & Cygwin

There are 3 build scripts:

./build.sh
./src/build.sh
./sandbox/build.sh

./build.sh - Calls other build.sh located in project directories.
src/build.sh and sandbox/build.sh - can also be called directly to just buid single project
./run.sh - this script can run linux and cygwin executable, script contains small pice of code that recognizes on what enviroment it's running.

Concept

  1. Simple to use as std::cout
  2. Colors support - I 😍 colors on output, evey one loves colors
  3. ostream manips must work this same way as they work on cout

To make usage as simple as using std::cout, there is global Log defined called stf::theLog, and usage is exacly this same as for std::cout for example

    stf::theLog.i << "This is info message" << std::endl;

Class Log is a container for Logger classes. For each serverity (debug/info/warning/error), it contains single Logger, named of first letter of serverity - like in Android Log 😄

Dir struct

|- bin 
|  `- <platform><architecture>_<configuration>
|
|- include
|- sandbox
|- src
`- tmp
   `- <platform><architecture>_<configuration>
      ` - <project_name>

bin - lib/exe and pdb files end up here colected per platform
include - library public include files
sandbox - code for test and develop (may contain local headers)
src - libaray source code (may contain local/private headers)
tmp - intermediete files, that are created in process of compilation organized per platform

Personaly I find such structure easy to manage, cross platform and obvius to any one who see it for first time.

.vcxproj config

To make this repo submodule ready prjects are configured with assumption that main project solution file will be located in root folder of project.

  • bin/lib/tmp is writen relative to $(SolutionDir)
$(SolutionDir)bin\win$(PlatformArchitecture)_$(Configuration)\
  • additional include files are relative to $(ProjectDir)
$(ProjectDir)..\include;

This way, after adding project as submodule structure of directories will look like this:

|- bin 
|  `- <platform><architecture>_<configuration>
|
|- @stf_logger
|  `- include
|  |- sandbox
|  `- src
|
`- tmp
   `- <platform><architecture>_<configuration>
      ` - <project_name>

TODO:

  • Log - store Loggers as shared_ptr: will be needed for registry
  • Log/Logger registry
  • Log sink support - so we can define for example file, attached per logger
  • Log builder (Java like) so we can define Log with own loggers, instead of encapsulated ones
  • Linux support
  • Formating - something like (should format contain/accept endl?)
    stf::theSys.i.format << stf::cyellow << "[INFO]" << stf::cgeen << stf::logtime(std::chrono::std::chrono::system_clock) << stf::creset << "] " << stf::logmsgbody

Sample call later:

    stf::theSys.i << "Sample message" << endl;<br>

Should output to console:
[INFO][15:30:01] Sample message

  • Move to cmake ? ( that would be a bit of overkill / I hate cmake 😕 )

About

Simple Logger for my needs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 92.6%
  • Shell 7.4%